akhauriyash/Code-Regression huggingface dataset:
/*
	##############################
	#  Author: Pratyush Gaurav   #
	#  College: NIT ROURKELA     #
	##############################
*/
#include <bits/stdc++.h>

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli > plli;
typedef vector<lli> vlli;
typedef vector<plli > vplli;

#define rep(i,a) for(i = 0 ; i < a ; i++)
#define repr(i,a) for(i = a ; i >= 0 ; i--)
#define REP(i,a,b) for(i = a ; i <= b ; i++)
#define REPR(i,a,b) for(i = a ; i >= b ; i--)
#define mem(a,b)memset(a,b,sizeof(a))
#define opt ios_base::sync_with_stdio(false);cin.tie(NULL);
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a)*((b)/gcd(a,b)))
#define sqr(x) (x)*(x)
#define all(a) a.begin(),a.end()

#define endl '\n'

const long long INF = 2000000000000;
const long long MOD = 1000000007;
const long long MAXN = 100005;

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

void solve()
{
    lli n,x,d;
    cin >> n >> d >> x;
    vlli v(n);
    lli i;
    rep(i,n)
        cin >> v[i];
    lli ans = 0;
    rep(i,n) {
        lli temp = 1;
        while(temp <= d) {
            ans++;
            temp += v[i];
        }
    }
    cout << ans + x << endl;
}
int main()
{
	opt;
	lli t = 1;
	while(t--)
	    solve();
	return 0;
}










Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        String ans = "Alice";
        if(A==B) ans = "Draw";
        if(A!=1&&A<B) ans = "Bob";
        if(B==1&&A!=1) ans = "Bob";
        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
        int p = sc.nextInt();
        int q = sc.nextInt();
        int r = sc.nextInt();
        
        if (p <= q && q <= r) {
            System.out.println((p + q));
        } else if (p <= r && r <= q) {
            System.out.println((p + r));
        } else if (q <= p && p <= r) {
            System.out.println((q + p));
        } else if (q <= r && r <= p) {
            System.out.println((q + r));
        } else if (r <= p && p <= q) {
            System.out.println((r + p));
        } else if (r <= q && q <= p) {
            System.out.println((r + q));
        }

		sc.close();
	}
}


Measured memory_bytes: 23124
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる


int main() {
  int n,a,b;
  cin >> n >> a >> b;
  int ans = 0;
  
  repo(i,n+1) {
  int x = i%10+(i/10)%10+(i/100)%10+(i/1000)%10+(i/10000)%10;
    if(a<=x && x<=b) ans+=i;
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lb long double 
using namespace std;
struct Po{lb x,y;}p1,p2,x;
int t;
void get(Po &x){scanf("%Lf %Lf",&x.x,&x.y);}
Po operator *(Po x,lb y){return (Po){x.x*y,x.y*y};}
Po operator +(Po x,Po y){return (Po){x.x+y.x,x.y+y.y};}
Po operator -(Po x,Po y){return (Po){x.x-y.x,x.y-y.y};}
lb operator *(Po x,Po y){return x.x*y.x+x.y*y.y;}
lb l2(Po x){return x.x*x.x+x.y*x.y;}
int main(){
	get(p1);get(p2);
	Po np=p2-p1;
	scanf("%d",&t);
	while (t--){
		get(x);
		Po nx=np*((np*(x-p1))/l2(np));
		x=p1+nx;
		printf("%.10Lf %.10Lf\n",x.x,x.y);
	}
	return 0;
}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n;
    std::cin >> n;
    std::vector<int> a(n);
    std::vector<i64> cnt(n + 1);
    for (auto &e : a) std::cin >> e;
    for (auto e : a) cnt[e]++;

    i64 s = 0;
    for (auto e : cnt) s += e * (e - 1) / 2;

    for (int i = 0; i < n; i++) std::cout << s - cnt[a[i]] + 1 << '\n';

    return 0;
}


Measured memory_bytes: 4992
#include<iostream>
#define int long long
using namespace std;
struct node
{
	int v,next;
};
node edge[10011];
int mod=1000000007;
int dp[5011][5011],g[5011],temp[5011],head[5011],size[5011],len;
bool used[5011];
void add(int x,int y)
{
	edge[++len].v=y;
	edge[len].next=head[x];
	head[x]=len;
	return;
}
void dfs(int x)
{
	size[x]=1;
	dp[x][1]=1;
	for (int i=head[x];i>0;i=edge[i].next)
	{
		if (used[edge[i].v])
			continue;
		used[edge[i].v]=1;
		dfs(edge[i].v);
		for (int k=0;k<=size[x];++k)
		{
			temp[k]=dp[x][k];
			dp[x][k]=0;
		}
		for (int k=0;k<=size[x];++k)
			for (int j=0;j<=size[edge[i].v];++j)
			{
				dp[x][k+j]+=(temp[k]*dp[edge[i].v][j])%mod;
				dp[x][k+j]%=mod;
			}
		size[x]+=size[edge[i].v];
	}
	for (int i=0;i<=size[x];i+=2)
	{
		dp[x][0]-=(dp[x][i]*g[i])%mod;
		dp[x][0]%=mod;
	}
	return;
}
signed main()
{
	int n,x,y;
	cin>>n;
	for (int i=1;i<=n-1;++i)
	{
		cin>>x>>y;
		add(x,y);
		add(y,x);
	}
	used[1]=1;
	g[0]=1;
	for (int i=2;i<=n;i+=2)
	{
		g[i]=g[i-2]*(i-1);
		g[i]%=mod;
	}
	dfs(1);
	cout<<(mod-dp[1][0]%mod)%mod<<endl;
	return 0;
}

Measured memory_bytes: 195072
#include <bits/stdc++.h>
using namespace std;
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
typedef long long ll;
typedef long double ld;
char str[100005];
const ll MOD = 1e9 + 7;
ll num[26];
int main() {
	int n;
	scanf("%d%s", &n, str);
	for (int i = 0; i < n; ++i) {
		++num[str[i] - 'a'];
	}
	ll ans = 1;
	for (int i = 0; i < 26; ++i) {
		ans = ans * (num[i] + 1) % MOD;
	}
	--ans;
	if (ans < 0) ans += MOD;
	printf("%lld\n", ans);
}


Measured memory_bytes: 384
A, B, C, D, E, F = [int(x) for x in input().split()]
 
X = []
for i in range(F // (100 * A) + 1):
	for j in range((F - 100 * A * i) // (100 * B) + 1):
		X.append(100 * A * i + 100 * B * j)
 
Y = []
for i in range(F // C + 1):
	for j in range((F - C * i) // D + 1):
		Y.append(C * i + D * j)
 
concentrationMAX = 0
ans = [100 * A,0]
 
for i in X:
	for j in Y:
		if i + j > 0:
			if i + j <= F:
				if i // 100 * E >= j:
					if j / (i + j) > concentrationMAX:
						concentrationMAX = j / (i + j)
						ans[0] = i + j
						ans[1] = j
 
print(ans[0],end=' ')
print(ans[1])

Measured memory_bytes: 52608
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int D = int.Parse(Console.ReadLine());
		int[]C = new int[26];
		string[]str = Console.ReadLine().Split();
		for(var i=0;i<26;i++){
			C[i] = int.Parse(str[i]);
		}
		int[,]A = new int[D,26];
		for(var i=0;i<D;i++){
			string[]str2 = Console.ReadLine().Split();
			for(var j=0;j<26;j++){
				A[i,j] = int.Parse(str2[j]);
			}
		}
		int[]ans = new int[D];
		int[]W = new int[26];
		for(var i=0;i<D;i++){
			int maxValue = 0;
			int maxj = 0;
			for(var j=0;j<26;j++){
				int value = A[i,j] + W[j]*(i+1-W[j])*100;
				if(value > maxValue){
					maxValue = value;
					maxj = j;
				}
			}
			ans[i] = maxj+1;
			W[maxj] = i+1;
		}
		for(var i=0;i<D;i++){
			Console.WriteLine(ans[i]);
		}
	}
}

Measured memory_bytes: 18432
var
 a:array[1..100001] of longint;
 n,m,k,i,j:longint;
procedure swap(var a, b: longint);
var
  temp: longint;
begin
  temp := a;
  a := b;
  b := temp;
end;

procedure quicksort(l, r: longint);
var
  border, i: longint;
begin
  if l < r then begin
    swap(a[random(r - l + 1) + l], a[r]);
    border := l;
    for i := l to r - 1 do
      if (a[i] < a[r]) or ((a[i] = a[r]) and (random(2) = 1)) then begin
        swap(a[border], a[i]);
        inc(border);
      end;
    swap(a[border], a[r]);
    quicksort(l, border - 1);
    quicksort(border + 1, r);
  end;
end;

begin
 readln(n);
 for i:=1 to n do
  readln(a[i]);
 quicksort(1,n);
 i:=1;
 k:=0;
 while (i<=n) do
  begin
   j:=i;
   while (j<=n) and (a[j]=a[j+1]) do
    inc(j);
    inc(k,(j-i+1) mod 2);
    i:=j+1;
  end;
 writeln(k);
end.



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

class BinaryTree
{
private:
        struct Node {
                int key;
                Node *parent, *left, *right;
                Node () : parent(nullptr), left(nullptr), right(nullptr) {}
                Node (int key) : key(key), parent(nullptr), left(nullptr), right(nullptr) {}
        };
public:
        BinaryTree () : root(nullptr) {}
        void insert(int k)
        {
                Node *data;
                Node **pos = find(k, &root);
        
                data = new Node(k);
                *pos = data;
                data->parent = *pos;
        }

        void preorder() { preorder(root); }
        void inorder() { inorder(root); }
private:
        Node *root;

        Node **find(int k, Node **node)
        {
                if ( *node == nullptr ) return ( node );
                if ( k < (*node)->key ) return ( find(k, &((*node)->left)) );
                else return ( find(k, &((*node)->right)) );
        }

        void preorder(Node *node)
        {
                if ( node == nullptr ) return;
                cout << " " << node->key;
                preorder(node->left);
                preorder(node->right);
        }

        void inorder(Node *node)
        {
                if ( node == nullptr ) return;
                inorder(node->left);
                cout << " " << node->key;
                inorder(node->right);
        }
};


int main()
{
        int n;
        BinaryTree tree;

        cin >> n;
        for ( int i = 0; i < n; i++ ) {
                string S;
                cin >> S;
                if ( S == "insert" ) {
                        int k;
                        cin >> k;
                        tree.insert(k);
                } else if ( S == "print" ) {
                        tree.inorder(); cout << endl;
                        tree.preorder(); cout << endl;
                }
        }
        
        return ( 0 );
}



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

int main() {
  int N;
  cin >> N;
  int T = N;
  int count = 0;
  while (N > 0){
    N = N / 10;
    count++;
  }
  if(count == 1){
    cout << T << endl;
  }
  if(count == 2){
    cout << 9 << endl;
  }
  if(count == 3){
    cout << 9 + T - 99 << endl;
  }
  if(count == 4){
    cout << 9 + 900 << endl;
  }
  if(count == 5){
    cout << 9 + 900 + T - 9999 << endl;
  }
  if(count == 6){
    cout << 9 + 900 + 90000 << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}
const LL M = (LL)1e9 + 7;
LL modkai(LL n) {
  LL ans = 1;
  REPC(i, 1, n) { ans = (ans * i) % M; }
  return ans;
}

int main() {
  LL n, m;
  cin >> n >> m;
  if (n > m)
    swap(n, m);
  LL ans = 0;
  if (m - n <= 1) {
    LL swapper = n == m ? 2 : 1;
    ans = modkai(n) * modkai(m) % M;
    ans = (swapper * ans) % M;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#define NIL NULL

struct node{
  struct node *right;
  struct node *left;
  struct node *p;
  int key;
};
  
typedef struct node * Node;

Node root;

void insert(int k)
{
  Node x;
  Node y;
  Node z;
  y = NIL;
  x = root;
  z = (Node)malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
    
  while(x!=NIL){
    y=x;
    if(z->key<x->key) x = x->left;
    else x = x->right;
  }
  z->p = y;
  
  if(y==NIL) root = z;
  else if(z->key<y->key) y->left = z;
  else y->right = z;
}
  
void inorderTreeWalk(Node x)
{
  if(x==NIL) return;
  inorderTreeWalk(x->left);
  printf(" %d",x->key);
  inorderTreeWalk(x->right);
}
  
void preorderTreeWalk(Node x)
{
  if(x==NIL) return;
    printf(" %d",x->key);
    preorderTreeWalk(x->left);
    preorderTreeWalk(x->right);    
}

int main()
{
  char str[7];
  int n,i,x;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",str);
    if(str[0]=='i'){
      scanf("%d",&x);
      insert(x);
    }
    else if(str[0]=='p'){
      inorderTreeWalk(root);
      printf("\n");
      preorderTreeWalk(root);
      printf("\n");
    }
  }
  return 0;    
}

Measured memory_bytes: 24040
<?php
$input = file_get_contents('php://stdin');
$inarr = explode(" ", $input);

$n = (int)$inarr[0];
$m = (int)$inarr[1];

$count = 0;
for($i=$n-1;$i>=0;$i--){
	$count+=$i;
}

for($i=$m-1;$i>=0;$i--){
	$count+=$i;

}

echo $count;

?>

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

int main() {
    int N; cin >> N;
    int ans = 0;
    int b = 1;
    vector<int> a(N);
    rep(i, N) {
        cin >> a.at(i);
    }
    rep(i, N) {
        b = a.at(b - 1);
        ans++;
        if (b == 2) {
            break;
        }
    }
    if (ans == N) {
        cout << -1 << endl;
    }
    else {
        cout << ans <<endl;
    }
}


Measured memory_bytes: 640
#include<stdio.h>

#define N 8
#define NOT_FREE 1
#define FREE -1

int row[N];
int col[N];

int Q[N][N];
int dpos[2*N];
int dneg[2*N];
void printboard();
void  putQueen(int);
int main(){

 
  int i,j,x,y,n;
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      Q[i][j] = 0;
    }
  }
   for(i=0;i<N;i++){
     row[i] =FREE;

   col[i] = FREE;
   }
  for(i=0;i<2*N;i++){
    dpos[i] =FREE;
    dneg[i] = FREE;
  }

  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d",&x,&y);
    Q[x][y]=1;
  }
  putQueen(0);
 
  return 0;
}

void putQueen(int i){
  int j;
  
  
  if(i==N){
 printboard();
    return ;
  }
 
  
  for(j=0;j<N;j++){
    if(col[j]== NOT_FREE || dpos[i+j]==NOT_FREE ||dneg[i-j+N-1]==NOT_FREE)
      {
	continue;}
    row[i]=j;
    col[j]=dpos[i+j]=dneg[i-j+N-1]=NOT_FREE;
    putQueen(i+1);
    row[i]=col[j]=dpos[i+j] = dneg[i-j+N-1]=FREE;
  }
  }



void printboard(){
  int i,j;
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(Q[i][j]){
	if(row[i]!=j) return ;
      }
    }
  }
  
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){

      if(row[i]==j)printf("Q");
      else printf(".");
    }printf("\n");
  }
  return;
}





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

// --------------------------------------------------------------------------------
#define fast_IO	ios_base::sync_with_stio(false),cin.tie(NULL),cout.tie(NULL);
#define ll long long 
#define mset(arr,val) memset(arr,val,sizeof(arr))
#define deb(name,value) cout <<"->>  "<<name<< "= " <<value<<" "
#define frepi(a,b,k) for(int i=a;i<=b;i+=k)
#define frepj(a,b,k) for(int j=a;j<=b;j+=k)
// --------------------------------------------------------------------------------


void solve()
{
    int n;cin>>n;
    int arr[n];
    map<int,int>mp;
    ll sum = 0;
    frepi(0,n-1,1)
    {
        cin>>arr[i];
        sum+=arr[i];
        mp[arr[i]]++;
    }
    int q;cin>>q;
    while(q--)
    {
        int b,c;
        cin>>b>>c;
        sum-=((long long)b*mp[b]);
        sum+=((long long)c*mp[b]);
        mp[c]+=mp[b];
        mp[b]=0;
        cout<<sum<<"\n";
    }

}

int main()
{
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
    }
    
}

Measured memory_bytes: 8332
#!/usr/bin/env python3
# -*- coding: utf-8 -*-*-

from sys import stdin


def main():
    K, N = list(map( int, stdin.readline().split() ))
    A = list(map(int, stdin.readline().split()))
    B = []
    B.append( A[0] + (K - A[-1]) )
    for i in range(N - 1):
        B.append(A[i + 1] - A[i])

    furthest = max(B)
    print(K - furthest)


if __name__ == "__main__":
    main()


Measured memory_bytes: 25880
#include <stdio.h>
 
int main() {

        int a,b,i,count=0;
        scanf("%d %d",&a,&b);
        char len[a+b+1];
        scanf("%s",len);
 
        for(i=0;i<a+b+1;i++){
            if(i!=a){
                if(len[i]>='0' && len[i]<='9') {
                count++;
                }
            } else if(len[i]=='-') {
                count++;
            }
        }

        if(count==a+b+1) {
            printf("Yes\n");
        } else {
            printf("No\n");
        }
        
        return 0;
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = 1'000'000'000'000'007ll;
const llong mod = 1e9+7;

int main() {
	llong X, Y;
	cin >> X >> Y;

	array<llong, 4> prise = {300000, 200000, 100000, 0};
	llong money = prise[min(X, 4ll) - 1] + prise[min(Y, 4ll) - 1];
	if (X == 1 && Y == 1) {
		money += 400000;
	}

	cout << money << endl;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using edge = struct {
  int to;
  int cost;
};

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

int main() {
  long long int N, M;
  cin >> N >> M;
  if (N == 1) {
    if (M == 1) {
      cout << 1 << endl;
    } else {
      cout << M - 2 << endl;
    }
  } else if (N == 2) {
    cout << 0 << endl;
  } else {
    if (M == 1) {
      cout << N - 2 << endl;
    } else if (M == 2) {
      cout << 0 << endl;
    } else {
      cout << N * M - (2 * (N + M)) + 4 << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;


int main() {

  int n,k;


  cin >> n;
  
  cin >> k;

  for(int i=0;i<k;i++) {

    int a,b;

    cin >> a >> b;

    if(n%2==0) {

      if(a>n/2) a=n+1-a;

      if(b>n/2) b=n+1-b;

    }

    else {

      if(a>n/2+1) a=n+1-a;

      if(b>n/2+1) b=n+1-b;

    }
      
    if(b<a) {

      if(b%3==0) cout << 3 << endl;

      else cout << b%3 << endl;

    }

    else {

      if(a%3==0) cout << 3 << endl;

      else cout << a%3 << endl;

    }

  }

  return 0;

}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int diff = b - a;
		
		int ha = 0;
		for (int i = 1; i < diff; i++) {
			ha += i;
		}
		
		System.out.println(ha - a);
		
		sc.close();
	}
}

Measured memory_bytes: 22996
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <climits>
using namespace std;

int main() {
	while(true) {
		int a[10],b[10],h,bl;
		fill(a,a+10,0);
		fill(b,b+10,0);
		h=bl=0;
		int a1,a2,a3,a4,b1,b2,b3,b4;
		if(scanf("%d%d%d%d%d%d%d%d",&a1,&a2,&a3,&a4,&b1,&b2,&b3,&b4)<8)break;
		if(a1==b1)h++;
		if(a2==b2)h++;
		if(a3==b3)h++;
		if(a4==b4)h++;
		a[a1]++;
		a[a2]++;
		a[a3]++;
		a[a4]++;
		b[b1]++;
		b[b2]++;
		b[b3]++;
		b[b4]++;
		for(int i = 0; i < 10; i++) bl+=min(a[i],b[i]);
		printf("%d %d\n",h,bl-h);
	}
	return 0;
}

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

int main() {
	int N;
	cin>>N;
	N = N % 10;
	if(N==2||N==4||N==5||N==7||N==9)cout<<"hon";
	else if(N==0||N==1||N==6||N==8)cout<<"pon";
	else cout<<"bon";
	return 0;
}


Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define endl '\n'

#define int long long

using namespace std;
const int MAXN = (1 << 20);

int A, B, C;

void read()
{
	cin >> A >> B >> C;	
}

int solve(int a, int b, int c) { if(a % 2 == 0) return 0; return b * c; }

void solve()
{
	int ans = solve(A, B, C);
	ans = min(ans, solve(A, C, B));
	ans = min(ans, solve(B, A, C));
	ans = min(ans, solve(B, C, A));
	ans = min(ans, solve(C, B, A));

	cout << ans << endl;
}

#undef int
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	read();
	solve();
	return 0;
}



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

using ll =  long long;
using pint =  pair<int,int>;

#define INF 2020202025
#define rep(i,n) for(int (i)=0,temp=(int)(n);(i)<temp;++(i)) 
#define repi(i,start,end) for(int (i)=(start),temp=(int)(end);i<(end);++(i))
#define rfor(v,x) for(const auto& (x) : (v)) //xは値を表す
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort((v), (v)+(n))
#define vsort(v) sort((v).begin(), (v).end())
#define vfsort(v,lambda) sort(all((v)),(lambda))
#define vint vector<int>
#define vvint vector<vector<int>> //vvint v(n,vint(n))のように宣言できる
#define vin(v) rep(i,(v).size()) {cin >> (v)[i];}
//最終奥義
#define int 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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//lambda式 -> [&](int x, int y){return x<y;}
//vector内の重複を削除-> v.erase(unique(all(v)),v.end());

signed main(void){
  int n;cin >> n;
  vint a(n);vin(a);

  vint r(n),l(n);
  r[n-1]=a[n-1];l[0]=a[0];
  repi(i,1,n)
    l[i]=l[i-1]+a[i];
  for(int i=n-2;i>=0;i--)
    r[i]=r[i+1]+a[i];
  int d=INF;
  rep(i,n-1)
    chmin(d,abs(l[i]-r[i+1]));

  printf("%lld\n",d);

}


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

int main() {
  int n, k, r, s, p;
  cin >> n >> k >> r >> s >> p;
  string t;
  cin >> t;
  
  int cour = 0;
  int cous = 0;
  int coup = 0;
  for(int i = k; i < n; i++){
    if(t.at(i) == t.at(i - k)){
      t.at(i) = 'x';
      continue;
    }
    if(t.at(i) == 'r') cour++;
    if(t.at(i) == 's') cous++;
    if(t.at(i) == 'p') coup++;
  }
  for(int i = 0; i < k; i++){
    if(t.at(i) == 'r') cour++;
    if(t.at(i) == 's') cous++;
    if(t.at(i) == 'p') coup++;
  }
  
  cout << cour * p + cous * r + coup * s << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>

using namespace std;

long long maxi(long long x, long long y, long long z)	{
  return max(max(x, y), z);
}

long long mini(long long x, long long y, long long z)	{
  return min(min(x, y), z);
}

int main()	{
  long long h, w; // height | width -
  cin >> h >> w;
  if (h % 3 == 0 || w % 3 == 0)	{
	cout << 0 << endl;
    return 0;
  }
  long long S = h * w;
  long long Sa = 0, Sb = 0, Sc = 0; // areas
  long long min = 1000000007;
  for (long long i = 0; i < h; i++)	{
    Sa = (i + 1) * w; // area of largest block
    Sb = (w / 2) * (h - i - 1);
    Sc = S - Sa - Sb;
    long long diff = maxi(Sa, Sb, Sc) - mini(Sa, Sb, Sc);
    if (diff < min)
      min = diff;
    Sb = w * ((h - i - 1) / 2);
    Sc = S - Sa - Sb;
    diff = maxi(Sa, Sb, Sc) - mini(Sa, Sb, Sc);
    if (diff < min)
      min = diff;
  }
  for (long long i = 0; i < w; i++)	{
    Sa = (i + 1) * h;
    Sb = (w - i - 1) * (h / 2);
    Sc = S - Sa - Sb;
    long long diff = maxi(Sa, Sb, Sc) - mini(Sa, Sb, Sc);
    if (diff < min)	{
      min = diff;
    }
    Sb = ((w - i - 1) / 2) * h;
    Sc = S - Sa - Sb;
    diff = maxi(Sa, Sb, Sc) - mini(Sa, Sb, Sc);
    if (diff < min)	{
      min = diff;
    }
  }
  cout << min << endl;
  return 0;
}

Measured memory_bytes: 3624
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define rep0(i,n) for (int i=0; i<=(int)(n); ++i)
#define rep1(i,n) for (int i=1; i<=(int)(n); ++i)
#define rrep(i,n) for (int i=(int)(n)-1; i>=0; --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
template<typename T> using Graph = vector<vector<T>>;
template<typename T> using Spacial = vector<vector<vector<T>>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1e9+7;
const int MOD2 = 998244353;
const double EPS = 1e-9;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

template<typename T> struct is_pair : false_type{};
template<typename T1, typename T2> struct is_pair<pair<T1, T2>> : true_type{};
template<typename T> struct is_vector : false_type{};
template<typename T> struct is_vector<vector<T>> : true_type{};

template<typename T1, typename T2>
istream &operator >> (istream &istr, pair<T1, T2> &p) {
  istr >> p.first >> p.second;
  return istr;
} 
template<typename T1, typename T2>
ostream &operator << (ostream &ostr, const pair<T1, T2> &p) {
  ostr << p.first << " " << p.second;
  return ostr;
}
template<typename T>
ostream &operator << (ostream &ostr, const vector<T> &vec) {
  if (vec.empty()) return ostr;
  bool vp = is_vector<T>() || is_pair<T>();
  ostr << vec.front();
  for (auto itr = ++vec.begin(); itr != vec.end(); ++itr) {
    ostr << (vp ? "\n" : " ") << *itr;
  }
  return ostr;
}

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

int modpow(int a, long long n, int mod = MOD) {
  int ret = 1;
  do {
    if (n & 1) ret = 1LL * ret * a % mod;
    a = 1LL * a * a % mod;
  } while (n >>= 1);
  return ret;
}

template<typename T>
T GCD(T a, T b) { return b ? GCD(b, a%b) : a; }
template<typename T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }

template<typename T1, typename T2>
bool CompareBySecond(pair<T1, T2> a, pair<T1, T2> b) {
  return a.second != b.second ? a.second < b.second : a.first < b.first;
}
template<typename T>
bool CompareBySlope(pair<T, T> a, pair<T, T> b) {
// counterclockwise from 12 o'clock direction
  if (a.first * b.first < 0) return a.first < b.first;
  if (a.first == 0) return a.second >= 0 || b.first > 0;
  if (b.first == 0) return b.second < 0 && a.first < 0;
  return a.second * b.first < a.first * b.second;
}


/* -------- <templates end> -------- */


void solve() {
  int n, a, b; cin >> n >> a >> b;
  int sum = a + b;
  int ans = n / sum * a + min(n % sum, a);
  cout << ans << endl;
}


/* -------- <programs end> -------- */


signed main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int N,Q,i;
long long int T;
long long int INF = 2000000000000000000LL;
long long int A[100000];
long long int D[100000];
long long int ans[100000];
long long int boundary;

int main(){

  scanf("%d %lld %d",&N,&T,&Q);
  
  for(i=0;i<N;i++){
    scanf("%lld %lld",&A[i],&D[i]);
    if(D[i]==1){
      ans[i]=A[i]+T;
    }else{
      ans[i]=A[i]-T;
    }
  }

  boundary=-INF;
  for(i=0;i<N;i++){
    if(i>0 && D[i-1]==1&&D[i]==2){
      boundary=(A[i-1]+A[i])/2;
    }
    
    if(D[i]==2 && ans[i] <= boundary){
      ans[i]=boundary;
    }
  }

  boundary=INF;
  for(i=N-1;i>=0;i--){
    if(i+1<N && D[i]==1&&D[i+1]==2){
      boundary=(A[i]+A[i+1])/2;
    }

    if(D[i]==1 && boundary <= ans[i]){
      ans[i]=boundary;
    }
  }

  for(i=0;i<Q;i++){
    int id;
    scanf("%d",&id);
    printf("%lld\n",ans[id-1]);
  }
  return 0;
}

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

int main(){
  long N,A,B,res = 0,diff,direc,small,big;
  cin >> N >> A >> B;
  if((B - A)%2 != 0){
  	small = (A -1) + 1 +(B - A - 1) / 2;
    big = (N - B) + 1 +(B - A - 1) / 2;
    res = min(small,big);
  }else{
  	res = (B - A)/2;
  }
  cout << res << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define debug(x) cerr<<#x<<" = "<<x
#define sp <<"  "
#define el <<endl
#define fgx cerr<<" ---------------------------------------------- "<<endl
#define uint unsigned int 
#define ULL unsigned long long
#define LDB long double
#define DB double
#define pii pair<int,int>
#define pli pair<LL,int>
#define mp make_pair
#define pb push_back
inline LL read(){
	LL nm=0; bool fh=true; char cw=getchar();
	for(;!isdigit(cw);cw=getchar()) fh^=(cw=='-');
 	for(;isdigit(cw);cw=getchar()) nm=nm*10+(cw-'0');
	return fh?nm:-nm;
}
#define mod 998244353
namespace  CALC{
	inline int add(int x,int y){return (x+y>=mod)?(x+y-mod):(x+y);}
	inline int mns(int x,int y){return (x-y<0)?(x-y+mod):(x-y);}
	inline int mul(int x,int y){return (LL)x*(LL)y%mod;}
	inline void upd(int &x,int y){x+=y;(x>=mod)?(x-=mod):0;}
	inline void dec(int &x,int y){x-=y;(x<0)?(x+=mod):0;}
	inline int qpow(int x,int sq){int res=1;for(;sq;sq>>=1,x=mul(x,x))if(sq&1)res=mul(res,x);return res;}
}using namespace CALC;
#define M 100200
#define INF 1000000000000000ll
map<LL,LL>F;
map<LL,bool>vis;
#define pll pair<LL,LL>
priority_queue<pll >Q;
LL n,A,B,C,D,ans;
inline void rw(LL x,LL w){if(!F.count(x))F[x]=INF;if(F[x]>w)F[x]=w,Q.push(mp(-w,x));}
inline void dfs5(LL x,LL now,bool ok=false){
	while(x%5==0){
		if(ok) rw(x,now);
		x/=5,now+=C,ok=true;
	}
	if(ok) rw(x,now);
}
inline void dfs3(LL x,LL now,bool ok=false){
	while(x%3==0) dfs5(x,now,ok),x/=3,now+=B,ok=true;
	dfs5(x,now,ok);
}
inline void dfs2(LL x,LL now,bool ok=false){
	while(!(x&1)) dfs3(x,now,ok),x>>=1,now+=A,ok=true;
	dfs3(x,now,ok);
}
inline LL solve(){
	F.clear(),vis.clear(); while(!Q.empty()) Q.pop(); ans=INF;
	n=read(),A=read(),B=read(),C=read(),D=read(),F[n]=0,Q.push(mp(0,n));
	// debug(ans)el;
	while(!Q.empty()){
		LL x=Q.top().second; Q.pop(); if(vis[x]) continue; vis[x]=true;
		if(INF/x>=D) ans=min(ans,x*D+F[x]);
		// debug(x)sp,debug(F[x])sp,debug(x*D+F[x])sp,debug(ans)el;
		if(x==n) dfs2(x,F[x]);
		if(x-1>0) dfs2(x-1,F[x]+D);
		if(x-2>0) dfs3(x-2,F[x]+D+D);
		if(x-3>0) dfs5(x-3,F[x]+D+D+D);
		if(x-4>0) dfs5(x-4,F[x]+D+D+D+D);
		dfs2(x+1,F[x]+D);
		dfs3(x+2,F[x]+D+D);
		dfs5(x+3,F[x]+D+D+D);
		dfs5(x+4,F[x]+D+D+D+D);
	}
	return ans;
}
int main(){
	for(int Cas=read();Cas;--Cas) printf("%lld\n",solve());
	return 0;
} 

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

using namespace std;

int main() {
  std::unordered_set<int> as;
  as.reserve(100000);
  int a;
  std::cin >> a;
  while (std::cin >> a) {
    if (as.count(a)) {
      as.erase(a);
    } else {
      as.insert(a);
    }
  }
  std::cout << as.size() << std::endl;
  return 0;
}


Measured memory_bytes: 4224
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _0017
{
    class Program
    {
        static void Main(string[] args)
        {
            Alphabet alphabet = new Alphabet();
            string str = "";
            while ((str = Console.ReadLine()) != null)
            {
                string[] data = new string[str.Length];
                string test = "";
                for (int i = 0; i < str.Length; ++i)
                {
                    data[i] = str.Substring(i, 1);
                }
              
                while (!(test.Contains("the") | test.Contains("this") | test.Contains("that")))
                {
                    test = "";
                    data = alphabet.CaesarCipher(data);
                    for (int i = 0; i < data.Length; ++i)
                    {
                        test += data[i];
                    }
                }
                Console.WriteLine(test);
            }
        }
    }
    class Alphabet
    {
        string[] alphabet = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q",
            "r","s","t","u","v","w","x","y","z","a","b","c","d","e","f","g","h","i","j","k","l","m"};
        public string StringTrans(string[] str, int i)
        {
            for (int j = 0; j < 26; ++j)
            {
                if (str[i] == alphabet[j])
                {
                    str[i] = alphabet[j + 1];
                    return str[i];
                }
                else
                {
                    str[i] = str[i];
                }
            }
            return str[i];
        }
        public string[] CaesarCipher(string[] str)
        {
            for (int i = 0; i < str.Length; ++i)
            {
                str[i] = StringTrans(str, i);
            }
            return str;
        }
    }
}



Measured memory_bytes: 13836
import java.util.Scanner;
    
    public class Main {
    	public static void main(String[] args){
    		Scanner sc = new Scanner(System.in);
    		// 整数の入力
    		int a = sc.nextInt();
    		int b = sc.nextInt();
    		double c = sc.nextDouble();
    		double d = sc.nextDouble();
    		double kaku = 0;
    		double answer = 0;
    		
    		
    		c=30*c+0.5*d;
    		d=6*d;
    		if(c>d) {
    			kaku=c-d;
    		}else {
    			kaku=d-c;
    		}
    		kaku=Math.cos(Math.toRadians(kaku));
    		
    		answer=a*a+b*b-2*a*b*kaku;
    		System.out.println(Math.sqrt(answer));
    		
    	}
    }

Measured memory_bytes: 36992
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
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; }


int main(){
    int x; cin >> x;
    int cnt = 0, turn = 0;
    while(!(cnt > 0 && turn == 0)){
        turn = (turn + x) % 360;
        cnt++;
    }
    cout << cnt << ln;
}

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

public class Main {
	static Scanner sc = new Scanner(System.in);
	static char[] S;
	static int pos;

	public static void main(String[] args) {
		S = sc.next().toCharArray();
		ExprOr formula = parseOr();
		formula.calcCost();
		System.out.println(formula.cost0 + " " + formula.cost1);
	}

	static ExprOr parseOr() {
		ExprOr ret = new ExprOr();
		ret.ands.add(parseAnd());
		while (pos < S.length && S[pos] == '|') {
			pos++;
			ret.ands.add(parseAnd());
		}
		return ret;
	}

	static ExprAnd parseAnd() {
		ExprAnd ret = new ExprAnd();
		ret.terms.add(parseTerm());
		while (pos < S.length && S[pos] == '&') {
			pos++;
			ret.terms.add(parseTerm());
		}
		return ret;
	}

	static Term parseTerm() {
		Term ret = new Term();
		if (S[pos] == '(') {
			pos++;
			ret.expr = parseOr();
		}
		pos++;
		return ret;
	}

	static abstract class Expr {
		int cost0, cost1;
	}

	static class ExprOr extends Expr {
		ArrayList<ExprAnd> ands = new ArrayList<>();

		void calcCost() {
			cost1 = Integer.MAX_VALUE;
			for (ExprAnd e : ands) {
				e.calcCost();
				cost1 = Math.min(cost1, cost0 + e.cost1);
				cost0 += e.cost0;
			}
//			System.err.println("Or " + cost0 + " " + cost1);
		}
	}

	static class ExprAnd extends Expr {
		ArrayList<Term> terms = new ArrayList<>();

		void calcCost() {
			cost0 = Integer.MAX_VALUE;
			for (Term t : terms) {
				t.calcCost();
				cost0 = Math.min(cost0, cost1 + t.cost0);
				cost1 += t.cost1;
			}
//			System.err.println("And " + cost0 + " " + cost1);
		}
	}


	static class Term extends Expr {
		ExprOr expr;

		void calcCost() {
			if (expr != null) {
				expr.calcCost();
				cost0 = expr.cost0;
				cost1 = expr.cost1;
			} else {
				cost0 = cost1 = 1;
			}
//			System.err.println("Term " + cost0 + " " + cost1);
		}
	}
}



Measured memory_bytes: 63496
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
typedef long long ll;



int main(){
    ll N,M;cin>>N>>M;
    ll ans=1;
    for(ll i=1;i*i<=M;i++){
        if(M%i==0&&M>=N*i)ans=max(ans,i);
        if(M%i==0&&i>=N)ans=max(ans,M/i);
    }
    cout<<ans<<endl;
}







Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=2e9;

ll ary[100010];

int main(){
    ll n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        ary[a]+=b;
    }
    for(int i=1;i<100005;i++){
        ary[i]+=ary[i-1];
    }
    for(int i=1;i<100005;i++){
        if(k<=ary[i]){
            cout<<i<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 1024
#include <stdio.h>
int main(void){
  int n,l[200],i,j,b,ans=0;
  scanf("%d",&n);
  for (i=0;i<n*2;i++) scanf("%d",&l[i]);
  for (i=0;i<n*2-1;i++){
    for (j=i+1;j<n*2;j++){
      if (l[i]>l[j]){
        b=l[i];
        l[i]=l[j];
        l[j]=b;
      }
    }
  }
  for (i=0;i<n;i++) ans+=l[i*2];
  printf("%d",ans);
  
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
int ans=0, n,m;
void dfs(int i, int s, int sum)
{
	if(sum==m && s==0)
	{
		ans++;
		return;
	}
	if(i==10 || s==0)return;
	dfs(i+1, s, sum);
	dfs(i+1, s-1, sum+i);
}
int main(void)
{
	while(1)
	{
		scanf("%d %d",&n,&m);
		if(n==0&&m==0)break;
		ans=0;
		dfs(0, n, 0);
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 1028
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <cstring>

using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using PP = pair<ll, pair<ll,ll>>;
#define rep(i,n) for (ll i = 0; i < (n); ++i)

string s;
int w[3];

int main() {
    cin >> s;

    rep(i,3){
        if (s[i] == 'R') w[i] = 1;
        else w[i] = 0;
    }

    if (w[0] == 0 && w[1] == 0 && w[2] == 0) cout << "0" << endl;
    else if (w[0] == 0 && w[1] == 0 && w[2] == 1) cout << "1" << endl;
    else if (w[0] == 0 && w[1] == 1 && w[2] == 0) cout << "1" << endl;
    else if (w[0] == 0 && w[1] == 1 && w[2] == 1) cout << "2" << endl;
    else if (w[0] == 1 && w[1] == 0 && w[2] == 0) cout << "1" << endl;
    else if (w[0] == 1 && w[1] == 0 && w[2] == 1) cout << "1" << endl;
    else if (w[0] == 1 && w[1] == 1 && w[2] == 0) cout << "2" << endl;
    else cout << "3" << endl;

    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <stdio.h>
#include <stdlib.h>
#include <cmath>
using namespace std;



int main(){
  int N, a[100]={0};
  int color[9]={0}, syurui = 0;
  int max, min;
  cin >> N;

  for(int i = 0; i < N; i++){
    cin >> a[i];
    if(a[i] < 3200)
      ++color[a[i]/400];
    else
      ++color[8];
  }
  for(int i = 0; i < 8; i++){
    if(color[i])
      syurui++;
  }

  max = min = syurui;
  max += color[8];
  
  if(min==0 && color[8])
    ++min;

  cout << min << " " << max << endl;
  


  

  return 0;
}



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

// (y,x) ~ (y+ky-1,x+kx-1) に +1 する累積和
// [0,cell.size()) x [0,cell.size()) で考える
void add(vector<vector<int> > &cell, int y, int x, int ky, int kx){

/*
    if(y<0){
        int d=-y;
        add(cell,0,            x,ky-d,kx);
        add(cell,cell.size()-d,x,d,   kx);
        return;
    }

    if(y>=cell.size()){
        int d=y-cell.size()+1;
        add(cell,0,            x,ky-d,kx);
        add(cell,cell.size()-d,x,d,   kx);
        return;
    }
*/
    if(y+ky>cell.size()){
        int d=y+ky-cell.size();
        add(cell,y,x,ky-d,kx);
        add(cell,0,x,d,kx);
        return;
    }

/*
    if(x<0){
        int d=-x;
        add(cell,y,0,            ky,kx-d);
        add(cell,y,cell.size()-d,ky,d);
        return;
    }

    if(x>=cell.size()){
        int d=x-cell.size()+1;
        add(cell,y,0,            ky,kx-d);
        add(cell,y,cell.size()-d,ky,d);
        return;
    }
*/
    if(x+kx>cell.size()){
        int d=x+kx-cell.size();
        add(cell,y,x,ky,kx-d);
        add(cell,y,0,ky,d);
        return;
    }

    cell[y][x]++;
    if(x+kx<cell.size()) cell[y][x+kx]--;
    if(y+ky<cell.size()) cell[y+ky][x]--;
    if(x+kx<cell.size() && y+ky<cell.size()) cell[y+ky][x+kx]++;

}

int main(){

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

    vector<vector<int> > cell(2*k,vector<int>(2*k,0));

    while(n--){
        int x,y;
        string c;
        cin>>x>>y>>c;

        if(c=="W") y+=k;

        x%=(2*k);
        y%=(2*k);

        //cout<<"1st"<<endl;
        add(cell,(y-k+1+2*k)%(2*k),(x-k+1+2*k)%(2*k),k,k);
        //show(cell);
        //cell=vector<vector<int> >(2*k,vector<int>(2*k,0));

        //cout<<"2nd"<<endl;
        add(cell,(y+1)%(2*k),(x+1)%(2*k),k,k);
        //show(cell);
        //cell=vector<vector<int> >(2*k,vector<int>(2*k,0));
    }

    //show(cell);

    for(int i=0;i<2*k;i++){
        for(int j=0;j<2*k-1;j++){
            cell[i][j+1]+=cell[i][j];
        }
    }

    for(int i=0;i<2*k-1;i++){
        for(int j=0;j<2*k;j++){
            cell[i+1][j]+=cell[i][j];
        }
    }

    int res=0;
    for(int i=0;i<2*k;i++){
        for(int j=0;j<2*k;j++){
            res=max(res,cell[i][j]);
            //cout<<cell[i][j];
        }
        //cout<<endl;
    }
    cout<<res<<endl;


	return 0;
}


Measured memory_bytes: 16000
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  string s;
  cin >> s;
  for (char& c : s) if (c == '7') {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}


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

using namespace std;

typedef long long int ll;
typedef vector<ll> vll;

#define fin(ans) cout << (ans) << endl;

template <typename T>
void V(T &n)
{
  for (ll i = 0; i < n.size(); i++)
  {
    cin >> n[i];
  }
}

template <typename T>
void Sort(T &n, ll a = 0, ll b = 0)
{
  if (b == 0)
  {
    return (sort(n.begin() + a, n.end()));
  }
  else
  {
    return (sort(n.begin() + a, n.begin() + b));
  }
}

void Main()
{
  ll n; cin >> n;
  vll d(n); V(d);
  Sort(d);
  fin(d[n / 2] - d[n / 2 - 1])
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}

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

#ifdef _DEBUG
#define ASSERT(x) assert(x)
#define DLOG(x) cout << #x " " << x << endl;
#else
#define ASSERT(x)
#define DLOG(x)
#endif

using namespace std;

int main() {
  int n, q;
  cin >> n >> q;
  vector<int> people(n, 0);
  map<int, set<int>> m;
  ostringstream ss;
  for (int i = 0; i < q; ++i) {
    int a, v;
    cin >> a >> v;
    --a;
    if (people[a]) {
      auto it = m.find(people[a]);
      if (it->second.size() > 1) {
        it->second.erase(a);
      } else {
        m.erase(it);
      }
    }
    people[a] += v;
    if (people[a]) {
      m[people[a]].insert(a);
    }
    if (m.empty()) {
      ss << 1 << " " << 0;
    } else {
      auto it = m.rbegin();
      ss << (*it->second.begin() + 1) << " " << it->first;
    }
    ss << endl;
  }

  cout << ss.str();
}



Measured memory_bytes: 13508
n,m = map(int,input().split())
A = list(map(int,input().split()))

su = [0,2,5,5,4,5,6,3,7,6]

dp = [-1]*(n+1)
dp[0] = 0

for i in range(1,n+1):
  for j in A:
    if i >= su[j]:
      dp[i] = max(dp[i],dp[i-su[j]]*10+j)
      
print(dp[-1])

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


	int n;
	cin>>n;
	int arr[n+1];
	map<int,int>mp;
	mp.insert(pair<int,int>(1,0));
	for (int i=2;i<=n;i++){
	    cin>>arr[i];
	    mp.insert(pair<int,int>(i,0));
	  // mp[arr[i]]++;
	}

	for(int i=1;i<=n;i++)
	{
	    mp[arr[i]]++;
	}
      for(int i=1;i<=n;i++)
	{
	    cout<<mp[i]<<"\n";
	}

	return 0;
}


Measured memory_bytes: 17724
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>0;--i)
#define yesno(flg) if(flg){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define Vi vector<int>
#define Vd vector<double>
#define Vl vector<long long>
#define pb(a) push_back(a)
using namespace std;

typedef long long ll;
const int inf=1000000000;
const int np=1000000007;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

Vd x(100000);
Vd r(100000);
int n;
double rec(double high,double low){
	if(high-low<0.0001)return high;
	double maxp=1000000;
	double minp=0;
	double mid=(high+low)/2;
	rep(i,n){
		double s=r[i]*r[i]-mid*mid;
		s=sqrt(s);
		maxp=min(maxp,x[i]+s);
		minp=max(minp,x[i]-s);
	}
	if(maxp<minp){
		return rec(mid,low);
	}else{
		return rec(high,mid);
	}
}
int main() {
	cin>>n;
	double minr=1000000;
	rep(i,n){
		cin>>x[i]>>r[i];
		minr=min(minr,r[i]);
	}

	printf("%0.4f\n",rec(minr,0));
	return 0;
}



Measured memory_bytes: 4244
n = int(input())
a = [int(e) for e in input().split()]
mat = [[a[j]>i  for j in range(n)] for i in range(max(a))]
sliced_mat = [[a for a,b in zip(row,row[1:]+[False]) if a and a!=b]for row in mat]
print(sum([len(row)for row in sliced_mat]))

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

int main() {
  int a,b,n,s;
  cin >> a >> b;
  n = b-a;
  s = 0;
  for(int i=0;i<=n;i++){
    s += i;
  }
  
  cout << s -b << endl;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    var ABC = listOfInt()
    val max = ABC.max()!!
    val sum = ABC.sum()
    val M = if (sum % 2 == max % 2) max else max + 1
    val ans = (M * 3 - sum) / 2
    println(ans)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfInt(d: Int = 0) = listOfString().map { it.toInt() + d }


Measured memory_bytes: 37768
#include<iostream>
using namespace std;
int main(){
  int n,k,x,y;
  cin>>n;
  cin>>k;
  cin>>x;
  cin>>y;
  int sum=0;
  for(int i=0;i<n;i++){
    if(i<k){
      sum+=x;
    }else{
      sum+=y;
    }
  }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int cnt;
  int N;
  char A[100] = {0,};
  char B[100] = {0,}; 
  char C[100] = {0,};
  int i;
  int op = 0;

  cnt = scanf("%d", &N);

  cnt = scanf("%s", A);
  cnt = scanf("%s", B);
  cnt = scanf("%s", C);

  for(i=0; i<N; i++){
    if ((A[i] == B[i]) && (B[i] == C[i])) continue;

    if (A[i] == B[i]) {
      op++;
      continue;
    }
    if (B[i] == C[i]) {
      op++;
      continue;
    }
    if (C[i] == A[i]) {
      op++;
      continue;
    }
    op += 2;
  }

  printf("%d", op);

  return 0;
}


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

using namespace std;


int main()
{
  int N, A[100000];

  cin >> N;
  for(int i = 0; i < N; i++) cin >> A[i];

  int dp[100001][2];
  fill_n(*dp, 100000 * 2, 1 << 30);
  dp[0][0] = dp[0][1] = 1;

  for(int i = 1; i < N; i++) {
    dp[i][0] = min(dp[i - 1][0] + (A[i - 1] - A[i] > 0), dp[i - 1][1] + 1);
    dp[i][1] = min(dp[i - 1][1] + (A[i - 1] - A[i] < 0), dp[i - 1][0] + 1);
  }

  cout << min(dp[N - 1][0], dp[N - 1][1]) << endl;

}

Measured memory_bytes: 1408