akhauriyash/Code-Regression huggingface dataset:
//
// Created by kashi on 27-07-2020.
//
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define Endl endl
#define int long long
int gcd(int a,int b){
    return b?gcd(b,a%b):a;
}
bool cmps(pair<int,int>p1,pair<int,int>p2) {
    return p1.ss<p2.ss;
}
int lcm(int a, int b){
    return (a*b)/gcd(a, b);
}

int32_t main() {
    string s,t;
    cin>>s>>t;

        int ans=t.size();
        int count=0;
        for(int i=0;i<=s.size()-t.size();i++){
            for(int j=0;j<t.size();j++){
                if(s[j+i]!=t[j])
                    count++;
            }
            ans=min(ans,count);
            count=0;
        }
        cout<<ans<<Endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
static const double PI = acos(-1);
static const int INF = 1e9+7;


class Node{
public:
	int location;
	int p,l,r;
	Node(){}
};

class Point{
public:
	int id,x,y;
	Point(){}
	Point(int id,int x,int y):id(id),x(x),y(y){}
	bool operator <(const Point &p)const{
		return id<p.id;
	}

	void print(){
		printf("%d\n",id);
	}
};

static const int MAX=1000000;
static const int NIL=-1;

int N;
Point P[MAX];
Node T[MAX];
int np;

bool lessX(const Point &p1,const Point &p2){
	return p1.x<p2.x;
}

bool lessY(const Point &p1,const Point &p2){
	return p1.y<p2.y;
}

int makeKDTree(int l,int r,int depth){
	if(l>=r)return NIL;
	int mid=(l+r)/2;
	int t=np++;
	if(depth%2==0){
		sort(P+l,P+r,lessX);
	}else{
		sort(P+l,P+r,lessY);
	}
	T[t].location=mid;
	T[t].l=makeKDTree(l,mid,depth+1);
	T[t].r=makeKDTree(mid+1,r,depth+1);
	return t;
}

void find(int v,int sx,int tx,int sy,int ty,int depth,vector<Point> &ans){
	int x=P[T[v].location].x;
	int y=P[T[v].location].y;
	if(sx<=x && x<=tx && sy<=y && y<=ty){
		ans.push_back(P[T[v].location]);
	}
	if(depth%2==0){
		if(T[v].l!=NIL){
			if(sx<=x)find(T[v].l,sx,tx,sy,ty,depth+1,ans);
		}
		if(T[v].r!=NIL){
			if(x<=tx)find(T[v].r,sx,tx,sy,ty,depth+1,ans);
		}
	}else{
		if(T[v].l!=NIL){
			if(sy<=y)find(T[v].l,sx,tx,sy,ty,depth+1,ans);
		}
		if(T[v].r!=NIL){
			if(y<=ty)find(T[v].r,sx,tx,sy,ty,depth+1,ans);
		}
	}
}

int main(void){
	int x,y;
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		scanf("%d %d",&x,&y);
		P[i]=Point(i,x,y);
		T[i].l=T[i].r=T[i].p=NIL;
	}
	np=0;
	int root=makeKDTree(0,N,0);

	int q;
	scanf("%d",&q);
	int sx,tx,sy,ty;
	vector<Point> ans;
	for(int i=0;i<q;i++){
		scanf("%d %d %d %d",&sx,&tx,&sy,&ty);
		ans.clear();
		find(root,sx,tx,sy,ty,0,ans);
		sort(ans.begin(),ans.end());
		for(int j=0;j<ans.size();j++){
			ans[j].print();
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 16488
import java.util.*;

class Main {
	public static void main (String[] args) {
	    Scanner sc = new Scanner(System.in);
	    int n = sc.nextInt();
	    int m = sc.nextInt();
	    
	    int div = m/n;
	    
	    while(true){
	        if(m%div == 0){
	            System.out.println(div);
	            break;
	        }
	    else       div--;
	    }     
	}
}

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

typedef long long ll;
using namespace std;

ll go(vector<pair<int,int> >a, bool f){
	multiset<pair<int,int> >l, r;
	for(int i = 0; i < a.size(); i++)
		l.insert(a[i]), r.insert({a[i].second, a[i].first});
	ll ret = 0, cur = 0;
	while(l.size()){
		pair<int,int> tmp;
		if(f){
			tmp = *r.begin();
			r.erase(r.begin());
			l.erase(l.find({tmp.second, tmp.first}));
		}
		else{
			tmp = *l.rbegin();
			l.erase(--l.end());
			r.erase(r.find({tmp.second, tmp.first}));
		}
		f = !f;
		if(cur >= tmp.first && cur <= tmp.second ||
				cur <= tmp.first && cur >= tmp.second)
			continue;
		if(abs(cur - tmp.first) > abs(cur - tmp.second))
			swap(tmp.first, tmp.second);
		ret += abs(cur - tmp.first);
		cur = tmp.first;
		//		cerr << cur << endl;
	}

	return ret + abs(cur);
}

int main() {
	ios::sync_with_stdio(false);
	//	srand(time(NULL));
	int n; cin >> n;
	vector<pair<int,int> >a(n);
	for(int i = 0; i < n; i++)
		cin >> a[i].first >> a[i].second;
	cout << max(go(a, 0), go(a, 1)) << endl;
	return 0;
}


Measured memory_bytes: 14080
// C - Pyramid

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int x[100], y[100], h[100];

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

	for (int i=0; i<N; i++) {
		cin >> x[i] >> y[i] >> h[i];
	}

	int ans_cx, ans_cy, ans_h;
	for (int cx=0; cx<=100; cx++) {
		for (int cy=0; cy<=100; cy++) {
			bool valid = true;
			int tmp_H = INF;

			for (int i=0; i<N; i++) {
				if (h[i] != 0) tmp_H = h[i] + abs(x[i] - cx) + abs(y[i] - cy);
			}

			for (int i=0; i<N; i++) {
				if (h[i] == 0) {
					if (tmp_H > h[i] + abs(x[i] - cx) + abs(y[i] - cy)) {
						valid = false;
						break;
					}
				} else {
					if (tmp_H != h[i] + abs(x[i] - cx) + abs(y[i] - cy)) {
						valid = false;
						break;
					}
				}
			}

			if (valid) {
				ans_cx = cx;
				ans_cy = cy;
				ans_h = tmp_H;
			}
		}
	}

	cout << ans_cx << " " << ans_cy << " " << ans_h << endl;

	return 0;
}

Measured memory_bytes: 3616
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0233
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int n = RInt();
                if (n == 0) break;

                Stack<string> res = new Stack<string>();
                while (n != 0)
                {
                    int q = n / -10;
                    int r = n - (q * -10);

                    if (r < 0)
                    {
                        r += 10;
                        q += 1;
                    }

                    res.Push(r.ToString());
                    n = q;
                }
                Console.WriteLine(WAr(res, string.Empty));
            }
        }
        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RArSt(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RArInt(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RArLong(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RArDouble(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }
}



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


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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int MC = 1e5 + 3;
int N;
LL C,x[MC],v[MC],s[MC];

int main(){
	cin >> N >> C;
	repp(i,1,N+1){
		cin >> x[i] >> v[i];
		s[i] = s[i-1] + v[i];
	}
	LL ans = 0;
	LL mx0 = 0 , mx1 = 0;
	repm(i,N,0){
		ans = max(ans,s[i]-x[i]+mx0);
		ans = max(ans,s[i]-2*x[i]+mx1);
		mx0 = max(mx0,s[N]-s[i-1]-2*(C-x[i]));
		mx1 = max(mx1,s[N]-s[i-1]-(C-x[i]));
	}
	cout << max(ans,mx1) << endl;
	return 0;
}


Measured memory_bytes: 2560
#include<stdio.h>
int main(){
    int n,k,q,i;
    int a[100001];
    int score[100001];
    
    scanf("%d %d %d",&n,&k,&q);
    for(i = 1 ; i <= q ; i++){
        scanf("%d",&a[i]);
    }
    for(i = 1 ; i <= n ; i++){
        score[i] = k;
    }
    
    for(i = 1 ; i <= q ; i++){
        score[a[i]]++;
    }
//    for(i = 1 ; i <= n ; i++) printf("%d ",score[i]);
    
    for(i = 1 ; i <= n ; i++){
        score[i] -= q;
        if(score[i] > 0) printf("Yes\n");
        else printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define N 3000005
#define endl "\n"
#define mod 1000000007
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	char ar[5];
	cin>>ar;

	ll i,j,k,l,a,b;
	a=(ar[0]-'0')*10+(ar[1]-'0');
	b=(ar[2]-'0')*10+(ar[3]-'0');


	if(a==0){
		if(b<=12&&b>0){
			cout<<"YYMM";
		}
		else {
			cout<<"NA";
		}
		return 0;
	}
	else if(b==0){
		if(a<=12&&a>0){
			cout<<"MMYY";
		}
		else{
			cout<<"NA";
		}
		return 0;
	}

	if(a<=12&&b<=12){
		cout<<"AMBIGUOUS";
	}
	else if(a<=12){	
		cout<<"MMYY";
	}
	else if(b<=12){
		cout<<"YYMM";
	}
	else{
		cout<<"NA";
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, _s, n) for(int i = _s, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;

#define repi(itr, ds) for(auto itr = ds.begin(); itr != ds.end(); itr++)
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for(T &x : vec) is >> x;
  return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "{";
  for(int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  }
  os << "}\n   ";
  return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
  os << "{";
  repi(itr, map_var) {
    os << *itr;
    itr++;
    if(itr != map_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
  os << "{";
  repi(itr, set_var) {
    os << *itr;
    itr++;
    if(itr != set_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}

#define DUMPOUT cerr

void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
  DUMPOUT << head;
  if(sizeof...(Tail) > 0) {
    DUMPOUT << ", ";
  }
  dump_func(std::move(tail)...);
}
#ifdef DEBUG_
#define DEB
#define dump(...)                                                             \
  DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                             \
          << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \
          << "    ",                                                          \
      dump_func(__VA_ARGS__)
#else
#define DEB if(false)
#define dump(...)
#endif

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

int main() {
  int N;
  cin >> N;
  auto v = vector<int>(N);
  REP(i, N) cin >> v[i];

  sort(ALL(v));
  double ans = v[0];
  REPS(i, 1, N) { ans = (ans + v[i]) / 2; }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
using namespace std;
int ai[200005],bi[200005];
int main()
{
     int n;
     scanf("%d",&n);
     for(int i=0;i<n;i++)
     {
        scanf("%d",&ai[i]);
        bi[i]=ai[i];
     }
    sort(bi,bi+n);
    for(int i=0;i<n;i++)
    {
        if(ai[i]<bi[n/2])
            printf("%d\n",bi[n/2]);
        else if(ai[i]>=bi[n/2])
            printf("%d\n",bi[(n-1)/2]);
    }
    return 0;
}


Measured memory_bytes: 3712
const line = require('fs').readFileSync('/dev/stdin', 'utf-8').split('\n');

const newNode = (id, arr) => {
    return {
        id: id,
        children: [...arr],
        parentNode: -1,
        depth: null
    };
};

const nodeToString = node => {
    const type = node.parentNode === -1 ? 'root'
               : node.children.length > 0 ? 'internal node'
               : 'leaf';
    const arr = `[${node.children.join(', ')}]`;
    return `node ${node.id}: parent = ${node.parentNode}, depth = ${node.depth}, ${type}, ${arr}`;
};

const setDepth = tree => {
    const root = tree.filter(x => x.parentNode === -1)[0];
    const helper = (node, n) => {
        node.depth = n;
        node.children.forEach(x => {
            helper(tree[x], n+1);
        });
    };
    helper(root, 0);
};

const n = parseInt(line[0]);
const data = line.slice(1, n+1)
                 .map(x => x.split(' ').map(Number));

const tree = data.map(x => {
    const id = x[0];
    const children = x.slice(2);
    return newNode(id, children);
});

tree.sort((a, b) => a.id - b.id);
tree.forEach((x, _, arr) => {
    x.children.forEach(y => {
        arr[y].parentNode = x.id;
    });
});

setDepth(tree);

console.log(tree.map(x => nodeToString(x)).join('\n'));



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

#define int long long
using namespace std;

int a[10];

signed main()
{
	int x;
	for (int i = 0; i < 4; i++) {
		cin >> x;
		a[x] ++;
	}
	if (a[1] && a[4] && a[7] && a[9]) {
		cout << "YES" << endl;
	} else{
		cout << "NO" << endl;
	}

    return 0;
}


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

using namespace std;

int main() {
	
	map<char, int> Map;
	Map['I'] = 1;
    Map['V'] = 5;
    Map['X'] = 10;
    Map['L'] = 50;
    Map['C'] = 100;
    Map['D'] = 500;
    Map['M'] = 1000;
    
    string roman_num;
    
    while( cin >> roman_num) {
    	
    	int sum = 0;
    	
    	for(int i=0;i<roman_num.size();i++) {
    		
    		if( Map[roman_num[i]] < Map[roman_num[i+1]] )
    		sum -= Map[roman_num[i]];
    		else
    		sum += Map[roman_num[i]];
    		
		}
    	
    	cout << sum << "\n";
    	
	}

	return 0;
}


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

const int M = 310;

typedef struct{
    vector<int> x, y;
}Doc;

string P, Q;
int N;
map<string, int> ntoi;
bool matrix[M][M];

int main(){
    for(int i=0; i<M; i++)
        matrix[i][i] = true;
    
    cin >> P >> Q;
    ntoi[P] = 0;
    ntoi[Q] = 1;
    matrix[ntoi[P]][ntoi[Q]] = true;
    
    cin >> N;
    vector<Doc> docs;
    for(int i=0; i<N; i++){
        auto doc = Doc();
        int m; cin >> m;
        for(int i=0; i<m; i++){
            string x, y; cin >> x >> y;
            if(ntoi.find(x) == ntoi.end())
                ntoi[x] = ntoi.size() + 1;
            if(ntoi.find(y) == ntoi.end())
                ntoi[y] = ntoi.size() + 1;
            doc.x.push_back(ntoi[x]);
            doc.y.push_back(ntoi[y]);
        }
        docs.push_back(doc);
    }
    
    vector<bool> done(N);
    bool updated = true;
    while(updated){
        updated = false;
        for(int i=0; i<N; i++) if(!done[i]){
            auto &doc = docs[i];
            
            bool flag = false;
            for(int j=0; j<doc.x.size(); j++){
                if(matrix[doc.x[j]][doc.y[j]]){
                    flag = true;
                    break;
                }
            }
            if(!flag) continue;
            
            for(int j=0; j<doc.x.size(); j++){
                for(int k=0; k<M; k++){
                    if(matrix[k][doc.x[j]])
                        matrix[k][doc.y[j]] = true;
                    if(matrix[doc.y[j]][k])
                        matrix[doc.x[j]][k] = true;
                }
            }
            done[i] = true;
            updated = true;
        }
    }
    
    bool cycle = false;
    for(int i=0; i<M; i++){
        for(int j=0; j<M; j++) if(i != j){
            cycle |= matrix[i][j] && matrix[j][i];
        }
    }
    
    cout << (cycle? "No": "Yes") << endl;
    
    return 0;
}

Measured memory_bytes: 4208
#include <iostream>
#include <vector>
#include <queue>
typedef std::pair<int , int> P;
struct edge{
    int en , d , c;
};
std::vector <edge> vec[10001];
int d[10001];
bool used[10001];
void init(int n){
    for(int i = 1;i <= n;i++){
        d[i] = 0 , used[i] = false , vec[i].clear();
    }
}
int main(){
    int n , m;
    while(std::cin >> n >> m){
        if(n == 0 && m == 0)
            break;
        init(n);
        for(int i = 0;i < m;i++){
            int u , v , d , c;
            std::cin >> u >> v >> d >> c;
            edge edge0; edge0.en = v , edge0.d = d , edge0.c = c;
            vec[u].push_back(edge0);
            edge0.en = u;
            vec[v].push_back(edge0);
        }
        std::priority_queue <P , std::vector<P> , std::greater<P> > pq;
        P P0; P0.first = 0 , P0.second = 1;
        pq.push(P0);
        while(!pq.empty()){
            P0 = pq.top() , pq.pop();
            int st = P0.second , dist = P0.first;
            if(used[st]){
                continue;
            }
            used[st] = true , d[st] = dist;
            for(int i = 0;i < vec[st].size();i++){
                if(!used[vec[st][i].en]){
                    P P1; P1.first = vec[st][i].d + dist , P1.second = vec[st][i].en;
                    pq.push(P1);
                }
            }
        }
        int ans = 0;
        for(int i = 2;i <= n;i++){
            int plus = 1001;
            for(int j = 0;j < vec[i].size();j++){
                if(d[i] == d[vec[i][j].en] + vec[i][j].d && vec[i][j].c < plus){
                    plus = vec[i][j].c;
                }
            }
            ans += plus;
        }
        std::cout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 5180
#include<stdio.h>
void swap(int *xp, int *yp) 
{ 
    int temp = *xp; 
    *xp = *yp; 
    *yp = temp; 
} 
  
int main() 
{ 
    int x, y, z; 
    scanf("%d %d %d", &x, &y, &z); 
    swap(&x, &y); 
  	swap(&x, &z);
  	printf("%4d%4d%4d", x,y,z);
  	return 0;
}

Measured memory_bytes: 128
n,m = map(int,input().split(' '))
if n >= m:
    print(0)
else:
    X = list(map(int,input().split(' ')))
    X.sort()
    dis = []
    for i in range(m - 1):
        dis.append(X[i + 1] - X[i])
    dis.sort(reverse = True)
    div = 0
    total = X[m - 1] - X[0]

    for i in range(n - 1):
        div += dis[i]
    print(total - div)

Measured memory_bytes: 13960
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
int main(){
    int n;cin >> n;
    vl a(n);rep(i,n) cin >> a[i];
    if(a[0]){
        cout << -1 << endl;
        return 0;
    }
    rep(i,n-1){
        if(a[i]+1<a[i+1]){
            cout << -1 << endl;
            return 0;
        }
    }
    map<ll,ll> mp;
    rep(i,n){
        mp[a[i]-i]=a[i];
    }
    ll ans=0;
    for(auto p:mp) ans+=p.se;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 14336
n=int(input())
ss=[int(input()) for _ in range(n)]

ss.sort()
ans=sum(ss)

if ans%10!=0:
  print(ans)
  exit()
elif ans%10==0:
  for s in ss:
    if s%10!=0:
      ans-=s
      print(ans)
      exit()
print(0)
      

Measured memory_bytes: 2940
#include<stdio.h>

int main(){

  int n,i,is=0;
  scanf("%d",&n);
  int a[n];

    for(i=0;i<n;i++){
      scanf("%d",&a[i]);
    }

      for(i=0;i<n;i++){
        if(a[i]%2==0){
          if(a[i]%3!=0&&a[i]%5!=0)is=1;
        }
      }
      if(is==0){
        printf("APPROVED\n");
      }else{
        printf("DENIED\n");
      }
      return 0;
}

Measured memory_bytes: 128
// C++ program to Find Number of digits  
// in base b. 
#include <iostream> 
#include <math.h>  
using namespace std; 
  
// function to print number of 
// digits 
void findNumberOfDigits(long n, long base) 
{ 
    // Calculating log using base 
    // changing property and then 
    // taking it floor and then  
    // adding 1. 
   long dig = (long)(floor( log(n) /  
                         log(base)) + 1);  
      
    // printing output 
    cout<<dig<<endl;
} 
  
// Driver method  
int main() 
{ 
    // taking inputs 
    long n,k;
    cin>>n>>k;
      
    // calling the method 
    findNumberOfDigits(n,k); 
    return 0; 
} 
  
// This code is contributed by Manish Shaw  
// (manishshaw1) 


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
#define N 200102
int n,p,f[N],inv[N],finv[N],bin[N],bn[N],s[3003][3003];
inline int C(int nn,int mm)
{
    if(nn<mm)return 0;
    return 1ll*f[nn]*finv[mm]%p*finv[nn-mm]%p;
}
int main()
{
    scanf("%d%d",&n,&p);
    f[0]=finv[0]=f[1]=finv[1]=inv[1]=1;
    for(int i=2;i<=20000;i++)
    {
        inv[i]=1ll*(p-p/i)*inv[p%i]%p;
        f[i]=1ll*f[i-1]*i%p;finv[i]=1ll*finv[i-1]*inv[i]%p;
    }
    bin[0]=1;bn[0]=2;
    for(int i=1;i<=n;i++)bin[i]=1ll*bin[i-1]*2%p,bn[i]=1ll*bn[i-1]*bn[i-1]%p;
    s[0][0]=1;
    for(int i=1;i<=n+1;i++)for(int j=1;j<=i;j++)s[i][j]=(s[i-1][j-1]+1ll*s[i-1][j]*j%p)%p;
    int ans=0;
    for(int i=0;i<=n;i++)
    {
        int te=0,w=1;
        for(int j=0;j<=i;j++)
        {
            te=(te+1ll*s[i+1][j+1]*bn[n-i]%p*w%p)%p;
            w=1ll*w*bin[n-i]%p;
        }
        te=1ll*te*C(n,i)%p;
        if(i&1)ans=(ans-te+p)%p;
        else ans=(ans+te)%p;
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 31548
all_text = []
while True:
    try:
        text = input().split()
        all_text.extend(text)
    except EOFError:
        break
text = ''.join(all_text)

count = [0]*32
for letter in text:
    i = ord(letter)
    if i < 64:
        continue
    else:
        i %= 32
    if i:
        count[i] += 1

for i in range(26):
    print(chr(i+ord('a')), ':', count[i+1])



Measured memory_bytes: 5568
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int n;
struct NOOD {
	int x;
	int pos;
}a[100010];
bool cmp(NOOD x, NOOD y) {
	if(x.pos == y.pos)return x.x > y.x;
	return x.pos < y.pos;
}
int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; i++)scanf("%d%d", &a[i].x, &a[i].pos);
	sort(a + 1, a + n + 1, cmp);
	printf("%d\n", a[1].pos + a[1].x);
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
int main()
  {int s; cin >> s;
  map<int, int> m;
  for (int i{1}; ; ++i)
    {if (m[s]) cout << i, exit(0);
    ++m[s]; s = s % 2 ? 3 * s + 1 : s / 2;}}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <string.h>
using namespace std;

typedef long long ll;
int N,M,P;
ll D[2510];
bool negative[2510];
ll inf = 1e18;
struct edge {int from,to; ll cost;};

vector<edge> v;

void shortest_path(int s){
	for(int i=1;i<=N;i++) D[i] = inf;
	D[s] = 0;
	for(int j=0;j<N-1;j++){
		//bool update = false;
		for(int i=0;i<v.size();i++){
			edge e = v[i];
			if(D[e.from] != inf && D[e.to] > D[e.from] + e.cost){
				D[e.to] = D[e.from] + e.cost;
				//update = true;
			}
		}
		//if(!update) break;
	}
}

void find_negative_loop(){
	//memset(D,0,sizeof(D));
	for(int i=1;i<=N;i++) negative[i] = false;
	for(int i=1;i<=N;i++){
		for(int j=0;j<v.size();j++){
			edge e = v[j];
			if(D[e.to]!=inf && D[e.to] > D[e.from] + e.cost){
				D[e.to] = D[e.from] + e.cost;
				negative[e.to] = true;
			}
			if(negative[e.from]) negative[e.to] = true;
		}
	}
}

int main(){
	cin >> N >> M >> P;
	for(int i=0;i<M;i++){
		int a,b,c;
		cin >> a >> b >> c;
		v.push_back((edge{a,b,P-c}));
	}
	shortest_path(1);
	ll ans = max(-D[N],0LL);
	find_negative_loop();
    cout << (negative[N]? -1:ans) << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
const long long INF = 1<<29;
int N,A,B,C;
vector<int> l;

int dfs(int i,int a,int b,int c){
    if(i==N){
        if(!a||!b||!c) return INF;
        else return abs(A-a) + abs(B-b) + abs(C-c);
    }
    int res = dfs(i+1,a,b,c);

    res = min(res,dfs(i+1,a+l[i],b,c) + (a?10:0));
    res = min(res,dfs(i+1,a,b+l[i],c) + (b?10:0));
    res = min(res,dfs(i+1,a,b,c+l[i]) + (c?10:0));

    return res;
}

int main(){
    cin >> N >> A >> B >> C;
    l.resize(N);
    rep(i,N){
        cin >> l[i];
    }
    cout << dfs(0,0,0,0) << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.readline
import time
from heapq import heappush, heappop
import math
import itertools as it
def inp():
    return int(input())
def inpl():
    return list(map(int, input().split()))
start_time = time.perf_counter()
# ------------------------------

x, k, d = inpl()

t = abs(x) // d

if k <= t:
    print(abs(x)-k*d)
    sys.exit()

k -= t
if k % 2 == 1:
    print(d - abs(x) % d)
else:
    print(abs(x) % d)

# -----------------------------
end_time = time.perf_counter()
print('time:', end_time-start_time, file=sys.stderr)


Measured memory_bytes: 9224
#include <bits/stdc++.h>
long long a[1000000],f[1000000];
using namespace std;
int main(){
	long long n,m,num,base=1000000007;
	cin>>n>>m;
	for (int i=0;i<=n;i++) a[i]=0;
	for (int i=0;i<m;i++){
		cin>>num;
		a[num]=1;
	}
	f[0]=1;
	if (a[1]==0) f[1]=1;
	else f[1]=0;
	for (int i=2;i<=n;i++)
		if (a[i]==0)
			f[i]=(f[i-1]+f[i-2])%base;
	cout<<f[n];
	return 0;
}

Measured memory_bytes: 5120
h,w=map(int,input().split())
ans=50000
for a,b in [(w,h),(h,w)]:
    for i in range(b):
        for c,d in [(a,b-i), (b-i,a)]:
            l=[i*a,c*(d//2),c*(d-d//2)]
            ans=min(ans,max(l)-min(l))
print(ans)


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

H, W = map(int, input().split())

if H == 1 or W == 1:
    ans = 1

else:
    if H%2 == 0:
        ans = H//2 * W

    else:
        ans = ((H//2)+1)*W - (W//2)

print(ans)

Measured memory_bytes: 2940
from math import sqrt


N,D = map(int,input().split())
X=[]
for i in range(N):
  x = list(map(int,input().split()))
  X.append(x)

list = []


for i in range(N):
  for k in range(i+1,N):
    list.append([i,k])
    
d_list = []

for plot in list:
  y = X[plot[0]]
  z = X[plot[1]]
 
  d = sqrt(sum([(yi-zi)**2 for yi, zi in zip(y,z)]))
  if d.is_integer():
    d_list.append(d)
    
    
print(len(d_list))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int N,K;
    cin >> N >> K;
    int ans=1;
    while(true){
        N=N/K;
        if(N==0){
            break;
        }
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<(S)<<endl
#define ck(a,b) (0<=(a)&&(a)<b)
using namespace std;

string abcgene(string anss){
	queue<string> q;
	q.push(anss);
	string c[3]={"A","B","C"};
	map<string,bool> m;
	m[anss]=true;
	while(!q.empty()){
		string s=q.front();
		q.pop();
		if(s=="ABC") return "Yes";
		REP(j,0,3){
			string tmps=s;
			int cnt=0;
			REP(i,0,(int) tmps.size()-2){
				if(tmps[i]=='A'&&tmps[i+1]=='B'&&tmps[i+2]=='C'){
					tmps.replace(i,3,c[j]);
					cnt++;
				}
			}
			if(cnt != count(tmps.begin(),tmps.end(),'A'+j)) continue;
			if(!m[tmps]) {
				m[tmps]=true;
				q.push(tmps);
			}
		}
	}
	return "No";
}

int main(){
	string ans;
	cin>>ans;
	p(abcgene(ans));
	return 0;
}

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

#define online_judge			freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fastio					ios::sync_with_stdio(false);cin.tie(0);
#define ll                      long long
#define pii                     pair<int, int>
#define pli                     pair<ll, int>
#define pil                     pair<int, ll>
#define pll                     pair<ll, ll>
#define vi                      vector<int>
#define vll                     vector<ll>
#define vb                      vector<bool>
#define vd                      vector<double>
#define vs                      vector<string>
#define ff                      first
#define ss                      second
#define pb                      push_back
#define eb                      emplace_back
#define ppb                     pop_back
#define pf                      push_front
#define ppf                     pop_front
#define vpii                    vector<pii>
#define vpll                    vector<pll>
#define umap                    unordered_map
#define all(x)                  x.begin(),x.end()
#define clr(a,b)                memset(a,b,sizeof a)
#define fr(i, n)                for(ll i=0; i<n;++i)
#define fr1(i, n)               for(ll i=1; i<=n; ++i)
#define rfr(i, n)                for(ll i=n-1; i>=0; --i)
#define precise(x)              cout<<fixed<<setprecision(x)
#define wh                        while
#define mp                        make_pair
#define le                        length()


ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

ll lcm(ll a,ll b) 
{ return (a*b)/__gcd(a,b); }

ll power(ll x,ll y,ll p) 
{ ll res=1; x=x%p;
    while(y>0) 
    { if (y&1) res=(res*x)%p; 
      y=y>>1; x=(x*x)%p; } 
    return res; } 
    
bool inside(ll x,ll y,ll n,ll m)
{
    return(x>=0&&x<n&&y>=0&&y<=m);
}   

void solve()
{    
	ll n,k;
	cin>>n>>k;
	k--;
	
	vll a(n);
	
	fr(i,n)
	{
		cin>>a[i];
	}
	ll mul=1;
	ll l=0,r=k+1;
	
	wh(r<=n-1)
	{
		if(a[l]>=a[r])
		{
			cout<<"No"<<endl;
		}
		else
		{
			cout<<"Yes"<<endl;
		}
		l++;r++;
	}
}
	

int main()
{
    fastio
//	int t;
//  	cin>>t;
//	fr1(i,t)
    {
//    	cout<<"Case "<<i<<":"<<endl;
        solve();
    }
    
	return 0;
}

Measured memory_bytes: 4784
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vii vector<vi>

const double pi = 3.14159265358979323846264;
const int mod=998244353;

//mod=1000000007

LL add(LL a,LL b){
  return (a+b)%mod;
}

LL sub(LL a,LL b){
  return (a+mod-b)%mod;
}

LL mul(LL a,LL b){
  return ((a % mod) * (b % mod)) % mod;
}

LL power(LL x,LL y){//繰り返し二乗法 単品利用可
  if(y==0)return 1;
  else if(y==1)return x%mod;
  else if(y%2==0){
    LL tmp=power(x, y/2) % mod;
    return tmp*tmp%mod;
  }else {
    LL tmp=power(x, y/2) % mod;
    return ((tmp*tmp)%mod)*x%mod;
  }
}

LL dvs(LL a,LL b){
  return mul(a,power(b,mod-2));
}

const int SIZE_mod=200005;
int invfact[SIZE_mod];
int fact[SIZE_mod];

LL factset(int a){//aまでの階乗%mod表を作成
  fact[0]=1;
  FORQ(i,1,a){
    fact[i]=mul(fact[i-1],i);
  }
}

LL cmbset(int a){//1~aまでの階乗と階乗数の逆元のmod(mod)を用意 O(a)
  factset(a);
  invfact[a]=power(fact[a],mod-2);
  invfact[0]=1;
  FORD(i,a,1){
    invfact[i]=mul(invfact[i+1],i+1);
  }

}

LL cmb(int n,int r){//nCr%mod  (cmbset後に使用)
  if(n<r||r<0||n<0)return 0;
  return mul(fact[n],mul(invfact[r],invfact[n-r]));
}

LL prm(int n,int r){//nPr%mod
    return mul(cmb(n,r),fact[n]);
}

LL homo(int n,int r){//nHr%mod
  return cmb(n+r-1,r);
}

int main(){
	int n;
	int d[101010]={};
	int a[101010]={};
	cin>>n;
	int mx=0;
	FOR(i,0,n){
		int t;
		cin>>t;
		d[t]++;
		a[i]=t;
		mx=max(mx,t);
	}
	if(a[0]==0&&d[0]==1){
		LL ans=1;
		FOR(i,1,mx+1){
			ans=mul(ans,power(d[i-1],d[i]));
		}
		cout<<ans;
	}else{
		cout<<0;
	}


}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()
// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
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); }
template< typename T > using matrix = vector< vector< T > >;

//FUNCTION  


void solve(void)
{
  int N;
  cin>>N;
  vector<string> vec(N);
  set<int> SET_A,SET_B;
  int ANS = 0;
  for (int i = 0; i < N; i++)
  {
    string str;
    cin>>str;
    for (int j = 0; j < str.size()-1; j++)
    {
      if(str[j] == 'A' && str[j+1] =='B')ANS++;
    }
    if(str[str.size()-1] == 'A' && str[0] == 'B')
    {
      SET_A.insert(N+i);
      SET_B.insert(N+i);
    }
    else if(str[str.size()-1] == 'A')SET_A.insert(i);
    else if(str[0] == 'B')SET_B.insert(2*N+i);
  
  
  }
  int T = 0;

  while(true)
  {

    static auto itr = SET_A.begin();
    if(T == 0)
    {
      if(SET_A.empty())break;
      itr = SET_A.begin();
      if(*itr >= N)
      {
        T = 0;
        // DEBUG(*itr);
      }
      SET_B.erase(*itr);
      SET_A.erase(*itr);
    }
    else
    {
      if(SET_B.empty())break;
      itr = SET_B.begin();
      if(*itr <2*N)
      {
        T = 0;
        // DEBUG(*itr);
      }
      SET_B.erase(*itr);
      SET_A.erase(*itr);
      ANS++;
    }
    T ^= 1;
    

  }
  cout<<ANS<<endl;
  
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


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

const int INF = 1001001001;

int a[12][12];

int main() {
	int n, m, x;
	cin >> n >> m >> x;
	vector<int> c(n);
	rep(i, n) {
		cin >> c[i];
		rep(j, m)cin >> a[i][j];
	}

	int ans = INF;
	rep(s, 1 << n) {
		int cost = 0;
		vector<int> d(m);
		rep(i, n) {
			if (s >> i & 1) {
				cost += c[i];
				rep(j, m)d[j] += a[i][j];
			}
		}
		bool ok = true;
		rep(j, m)if (d[j] < x)ok = false;
		if (ok)ans = min(ans, cost);
	}
	if (ans == INF)cout << -1 << endl;
	else cout << ans << endl;
	return 0;
	
}






Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define tr(v, it) for(auto const& it: v)
#define ll long long
#define for_in(i, n) for(ll i = 0; i<n; i++)
#define ios ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
vector< ll > l(300005);
vector< ll > r(300005);
vector<ll> v(300005);
ll INF=1e15;

int main()
{
    ios
   ll n;
   cin>>n;
   for_in(i, 3*n)
   {
       cin>>v[i];
   }
   
   priority_queue< ll > pq;
   priority_queue< ll, vector< ll >, greater< ll > > pq2;
   
   ll csum=0;
   for_in(i, 3*n)
   {
       pq2.push(v[i]);
       csum+=v[i];
       if(pq2.size()>n){csum-=pq2.top();pq2.pop();}
       if(pq2.size() == n) l[i]=csum;
       else l[i]=-INF;
   }
   csum=0;
   
   for(ll i=3*n-1;i>=0;i--)
   {
       pq.push(v[i]);
       csum+=v[i];
       if(pq.size()>n){csum-=pq.top();pq.pop();}
       if(pq.size() == n) r[i]=csum;
       else r[i] = INF;
   }
   ll ans= -INF;
   for_in(i, 3*n-1)
   {
       ans = max(ans, l[i] - r[i+1]);
   }
   cout<<ans<<endl;
   
   
   return 0;
}

Measured memory_bytes: 9588
n = int(input())
pre_x = 0
pre_y = 0
pre_t = 0
flag = True
for i in range(n):
    t,x,y = map(int,input().split())
    way_min = x-pre_x+y-pre_y
    if (t-pre_t-way_min) % 2 == 0 and t-pre_t>=way_min:
        pre_x=x
        pre_y=y
        pre_t=t
    else :
        flag=False
        break
if(flag):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
using ll = long long;
using namespace std;

int main(){
    string s;
    cin >> s;
    int p = 0;
    bool flag;
    string t = "";
    string dic[6] = { "dreameraser", "dreamerase", "dreamer", "dream", "eraser", "erase"};
    while(s != t){
        flag = true;
        REP(i, 6){
            if(s.substr(p, dic[i].length()) == dic[i]){
                t += dic[i];
                p += dic[i].length();
                flag = false;
                break;
            }
        }
        if(flag){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 640
#include <iostream>

int main()
{
	int n, m, readValue;
	std::cin >> n >> m;

	int* matrixA = new int[n*m];
	for (int i = 0; i < n*m; i++) {
			std::cin >> readValue;
			matrixA[i] = readValue;
	}

	int* matrixB = new int[m];
	for (int j = 0; j < m; j++) {
		std::cin >> readValue;
		matrixB[j] = readValue;
	}

	for (int i = 0; i < n; i++) {
		int sum = 0;
		for (int j = 0; j < m; j++) {
			sum += matrixA[i*m + j] * matrixB[j];
		}
		std::cout << sum << "\n";
	}

    return 0;
}




Measured memory_bytes: 3144
package main

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

func main() {
	sc := NewScanner()

	mp := map[int]struct{}{}
	n := sc.NextInt()
	random := 0
	for i := 0; i < n; i++ {
		tmp := sc.NextInt()
		if tmp < 3200 {
			mp[tmp/400] = struct{}{}
		} else {
			random++
		}
	}
	min := 0
	if len(mp) > 0 {
		min = len(mp)
	} else {
		min = 1
	}

	mx := 0
	mx = len(mp) + random
	fmt.Printf("%d %d\n", min, mx)
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
using namespace std;
int mday(int y,int m){
  if(y%3==0) return 20;
  if(m%2==1) return 20;
  return 19;
}

int tbl[1000][50][50];

int main(){
  int cnt = 0;
  for(int y=1;y<1000;++y){
    for(int m=1;m<=10;++m){
      for(int d=1;d<=mday(y,m);++d){
	tbl[y][m][d] = ++cnt;
      }
    }
  }
  int n;
  cin >> n;
  while(n--){
    int y,m,d;
    cin >> y >> m >> d;
    cout << 196470-tbl[y][m][d]+1 << endl;
  }
}

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

using namespace std;
typedef long long ll;
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;
const ll INF=1000000000000000;

vector<ll> pw2(51,1); vector<ll> pw10(19,1);
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll mid(ll x,ll y,ll z){return x>y?y>=z?y:min(z,x):x>=z?x:min(y,z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll myceil(ll x,ll y){if(x<=y) return 1;else if(x%y==0) return x/y;else return x/y+1;}
vector<ll> divisor(ll x){
	vector<ll> div;
	for(int i=1;i*i<=x;i++){
		if(i*i!=x && x%i==0){
			div.pb(i);
			div.pb(x/i);
		}
		else if(x%i==0) div.pb(i);
	}
	return div;
}
vector<ll> vectorprime(ll x){
	vector<bool> is_prime(x+1);
	vector<ll> prime;
	rep(i,x+1) is_prime[i]=true;
	is_prime[0]=is_prime[1]=false;
	for(int i=2;i<=x;i++){
		if(is_prime[i]){
			prime.pb(i);
		}
		for(int j=i*2;j<=x;j+=i) is_prime[j]=false;
	}
	return prime;
}

//a,b x
int main(){
	ll N; cin>>N;
	bool ans=false;
	rep(i,N){
		ll tmp; cin>>tmp;
		if(tmp%2==1) ans=true;
	}
	if(ans) cout<<"first";
	else cout<<"second";
}

Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');

var g_input = '';
process.stdin.on('data', function(chunk) {
    g_input += chunk;
});

process.stdin.on('end', function() {
    Main(g_input.split(/\r?\n/));
});

function Main(input) {

    var ab = input[0].split(' ');
    var a = parseInt(ab[0], 10);
    var b = parseInt(ab[1], 10);

    if (a > 8 || b > 8) {
        console.log(':(');
    } else {
        console.log('Yay!');
    }

    return 0;
}


Measured memory_bytes: 21192
def main():
  import sys
  input = sys.stdin.readline
  n = int(input())
  a = [int(i) for i in input().split()]
  Ss = set(a)
  s = list(Ss)
  import collections
  c = collections.Counter(a)
  j = 0
  #print(c[a[0]])
  for i in range(len(s)):
    j += int(c[s[i]]*(c[s[i]]-1)/2)
  #print(j)
  for i in range(n):
    if c[a[i]] >= 2:
      print(int(j-(c[a[i]]-1)))
    else:
      print(j)
if __name__ == '__main__':
    main()

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

int main() {
  int n, p; cin>>n>>p;
  string s; cin>>s;
  vector<long long> v(p+1, 0);
  v[0] = 1;

  int cur = 0, e = 1;
  for (int i = s.size() - 1; i >= 0; i--) {
    cur = (cur + (s[i] - '0') * e) % p;
    e = (e * 10) % p;
    ++v[cur];
  }

  long long ans = 0;
  if (p == 2) {
    for (int i = 0; i < n; i++) {
      if ((s[i] - '0') % 2 == 0) ans += i+1;
    }
  } else if (p == 5) {
    for (int i = 0; i < n; i++) {
      if (s[i] == '0' or s[i] == '5') ans += i+1;
    }
  } else {
    for (int i = 0; i < p+1; i++) {
      ans += v[i] * (v[i] - 1) / 2;
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 640
<?php
  fscanf(STDIN,"%d %d %d",$n,$a,$b);
  $count = 0;
  for($i=1; $i<=$n; $i++){
    $sum = 0;
    for($j=0; $j<strlen($i); $j++){
      $sum += strval($i)[$j];
    }
    if($sum >= $a && $sum <= $b){
      $count += $i;
    }
  }
  echo $count."\n";

Measured memory_bytes: 4604
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define range_for(i, b, e) for(int i=(b), i##_len=(e); i<=i##_len; ++i)
# define ALL(x) (x).begin(), (x).end()
# define RALL(x) (x).rbegin(), (x).rend()
# define pb push_back
# define len(x) ((int)(x).size())
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define debug(x) std::cerr<<#x<<": "<<(x)<<endl;
# define LINT_MAX (LONG_LONG_MAX)
# define cauto const auto
using namespace std;
using lint = long long;
template <class Type> inline constexpr bool InRange(const Type& x, const Type& i, const Type& a) { return (i <= x) && (x <= a); }
template<class Integer>bool chmax(Integer &a, const Integer &b) { if (a<b) { a=b; return 1; } return 0; }
template<class Integer>bool chmin(Integer &a, const Integer &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Integer>bool IsOdd(Integer &n) { return n & 1; }
template<class Integer>bool IsEven(Integer &n) { return !(n & 1); }
int ctoi(const char c) { return ('0' <= c && c <= '9') ? (c - '0') : -1; }
string YesNo(bool b) { return b ? "Yes" : "No"; }
string YESNO(bool b) { return b ? "YES" : "NO"; }
string yesno(bool b) { return b ? "yes" : "no"; }
static const lint MOD9 = (lint)1e9+7;
int dy[4] = {0, 1, 0, -1};
int dx[4] = {1, 0, -1, 0};

// 整数の桁数を返す ( log(N) )
template <class Integer> Integer GetDigit(Integer n) {
    Integer d = 0;
    while (n) {
        n /= 10;
        d++;
    }
    return d;
}

// 素数かどうかを返す ( O(sqrt(N)) )
template <class Integer>
constexpr bool IsPrime(const Integer n) noexcept {
    if (n < 4) return n == 2 || n == 3;
    if (n % 2 == 0 || n % 3 == 0 || (n % 6 != 1 && n % 6 != 5)) return false;
    for (Integer i = 5; i * i <= n; i += 6) if (n % i == 0 || n % (i + 2) == 0) return false;
    return true;
}

int FizzBuzz(int n)
{
    if (n % 3 == 0 or n % 5 == 0) return 0;
    else return n;
}

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

    lint sum = 0;
    reps (i, N)
    {
        sum += FizzBuzz(i);
    }

    cout << sum << endl;

    return 0;
}



Measured memory_bytes: 3628