akhauriyash/Code-Regression huggingface dataset:
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*                                                    
      I ♥ CLARICE STARLING...                                                               
        EXPLAINATION BELOW->
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
const ll INF = (ll)2e18 + 77;
void solve()
{
   int n,i;cin>>n;
   ll sum=0ll;
   ll A[n];
   fo(i,0,n)cin>>A[i];
   ll mx=A[0];
   fo(i,1,n)
   {
       if(mx>A[i])sum+=mx-A[i];
       mx=max(mx,A[i]);
   }
   cout<<sum<<"\n";
}
int main()
{
   fastio
   //Test_cases
   solve();
  return 0;
}
//**always check if you are not killing input in between
//map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration no greater<int>
//if you want to apply lowerbound on set use s.lower_bound(key),not the one used for vector
// Syntax to create a min heap for priority queue priority_queue <int, vector<int>, greater<int>>; 
//for modinverse use modularexponention(x,M-2,M);
//for "each" subtraction from ans(ans-k) if(ans<0) do ans+=MOD,ans%=MOD
//vector<vector<int>>dp(201,vector<int>(n+1)); A way to initialize vector of vector
//string2=string1.substr(pos,length);if len no specified then till end
//void fill (ForwardIterator first, ForwardIterator last, const T& val);
//The range filled is [first,last), which contains all the elements between first and last, including the element pointed by first but not the element pointed by last.


//If wrong on pretest 2 means logically wrong
/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
*/


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

int main() {
	int N,a[120];
	cin>>N;
	for(int i=0;i<N;i++){
		cin >>a[i];
	}
	sort(a,a+N,greater<int>());
	int A=0,B=0;
	for(int i=0;i<N;i++){
		if(i%2==0){
			A+=a[i];
		}
		else{
			B+=a[i];
		}
	}
	cout<<A-B<<endl;
	
	return 0;
}

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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    char a,b,c;
    cin >> a >> b >> c;
    if( a==b && b == c){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cassert>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> PLL;

int main() {
    int N;
    cin >> N;
    for (;N--;) {
        int src, dst;
        cin >> src >> dst;

        if (src < dst) {
            cout << src;
            for (int j = src+1; j <= dst; ++j) {
                cout << ' ' << j;
            }
            cout << endl;
        } else {
            cout << src;
            if (src <= 5) {
                for (int j = src-1; j >= dst; --j) {
                    cout << ' ' << j;
                }
            } else {
                for (int j = src+1; j <= 9; ++j) {
                    cout << ' ' << j;
                }
                if (dst <= 5) {
                    for (int j = 5; j >= dst; --j) {
                        cout << ' ' << j;
                    }
                } else {
                    for (int j = 5; j >= 0; --j) {
                        cout << ' ' << j;
                    }
                    for (int j = 1; j <= dst; ++j) {
                        cout << ' ' << j;
                    }
                }
            }
            cout << endl;
        }

    }

    return 0;
}

Measured memory_bytes: 3096
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;
#define ms(a) memset(a,0,sizeof(a))
#define N


int main(){
	int a,b,c,k,maxs,flag;
	while(cin>>a>>b>>c>>k){
		maxs=a;
		flag=1;
		if(b>maxs){
			maxs=b;
			flag=2;
		}			
		if(c>maxs){
			maxs=c;
			flag=3;
		}
		for(int i=1;i<=k;i++){
			maxs=maxs*2;
		}
		if(flag==1){
			cout<<maxs+b+c<<endl;
		}
		else if(flag==2){
			cout<<maxs+c+a<<endl;
		}
		else if(flag==3){
			cout<<maxs+b+a<<endl;
		}
		
	}


	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <string>
#include<vector>
#include<cmath>
typedef long long ll;

using namespace std;

int check(int x,int y, vector<int> xs, vector<int> ys, vector<int> hs) {
	int flg = 1;
	int h;
	for (int i = 0; i < xs.size(); i++) {
		if (hs[i] != 0) {
			h = hs[i] + abs(xs[i] - x) + abs(ys[i] - y);
			break;
		}
	}

	for (int i = 0; i < xs.size(); i++) {
		if (hs[i] == 0) {
			if (h - abs(xs[i] - x) - abs(ys[i] - y) > 0) flg = 0;
		}
		else {
			if (h != hs[i] + abs(xs[i] - x) + abs(ys[i] - y)) flg = 0;
		}
	}
	if (flg) {
		cout << x <<" "<< y << " " << h<<endl;
	}
	return flg;
}

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

	vector<int> xs(n);
	vector<int> ys(n);
	vector<int> hs(n);
	for (int i = 0; i < n; i++) {
		cin >> xs[i] >> ys[i] >> hs[i];
	}
	for (int i = 0; i <= 100; i++) {
		for (int j = 0; j <= 100; j++) {
			if(check(i, j, xs, ys, hs)) return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
import numpy as np

n = int(input())
v = np.array(list(map(int, input().split())))
c = np.array(list(map(int, input().split())))

diff = v - c
diff = np.sort(diff)[::-1]

ans = 0
for i in range(n):
    if diff[i] <= 0:
        break
    ans += diff[i]

print(ans)



Measured memory_bytes: 21292
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mii map <int, int>
#define mll map <ll, ll>
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vi vector <int>
#define vd vector <double>
#define vll vector <ll>
#define fi first
#define se second
#define si set <int>
#define sll set <ll>
#define spii set <pii>
#define vs vector <string>
#define vpii vector <pair <int,int> >
#define vpll vector <pair <long long,long long> >
#define vvi vector <vector <int> >
#define vvpii vector <vector <pii > >
#define forn(i, n) for (int i = 0; i < (n); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define for1(i, n) for (int i = 1; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()


using namespace std;
const ll INFLL = 1e18;
const int MAXN = 1e6+100;
const ll INF = 1e9;
const ll mod1=1e9+7;
const ll mod2=2e9+11;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
    freopen("a.in","r",stdin);
    #endif
    int n;
    cin>>n;
    int k;
    cin>>k;
    int c;
    cin>>c;
    string s;
    cin>>s;
    deque <int> right,left;
    int now=n-1;
    int wn=INF;
    while (now>=0)
    {
        if (s[now]=='x')
        {
            now--;
            continue;
        }
        if (wn-now>c)
            wn=now,right.push_front(now);
        now--;
    }
    if (right.size()&&right.front()==0)
        right.pop_front();
    now=0;
    wn=-INF;
    for (int i=0;i<n;i++)
    {
        if (s[i]=='x')
            continue;
        if (right.size()&&right.front()==i)
            right.pop_front();
        while (now<i)
        {
            if (s[now]=='x')
            {
                now++;
                continue;
            }
            if (right.size()&&right.front()-now<=c)
                break;
            if (now-wn>c)
                wn=now,left.push_front(now);
            now++;
        }
        if ((int)right.size()+(int)left.size()<k)
            cout<<i+1<<'\n';
        while (now<=i)
        {
            if (s[now]=='x')
            {
                now++;
                continue;
            }
            if (right.size()&&right.front()-now<=c)
                break;
            if (now-wn>c)
                wn=now,left.push_front(now);
            now++;
        }

    }




}

Measured memory_bytes: 2580
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
#include<map>
#include<set>
#include<stdio.h>
const int INF =100000000;
using namespace std;
int main(){
  int n, m, a[1000];
  while(true){
    cin>>n>>m;
    if(n==0 && m==0){
      break;
    }
    int card = 0, count = 0;
    for(int i = 0; i < n; i++){
      for(int k = i + 1; k < n; k++){
        card++;
      }
    }
    for(int i = 0; i < n; i++){
      cin>>a[i];
    }
    int sum[card];
    for(int i = 0; i < n; i++){
      for(int k = i + 1; k < n; k++){
        sum[count] = a[i] + a[k];
        count++;
      }
    }
    sort(sum, sum+card);
    for(int i = 0; i < card-1; i++){
      if(sum[0] > m){
        cout<<"NONE"<<endl;
        i = card + 1;
      }else{
      if(sum[i] <= m && sum[i+1] > m){
        cout<<sum[i]<<endl;
        i = card +1;
      }
     }
    }
    if(sum[card-1] <= m){
      cout<<sum[card-1]<<endl;
    }
  }
  return 0;
}



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

int main()
{

    long n, m, b, c, d, flag;
    vector<long> a;
    vector<pair<long, long>> pairs;

    cin >> n >> m;

    for (int i = 0; i < n; i++)
    {
        int tmp;
        cin >> tmp;
        a.push_back(tmp);
    }
    sort(a.begin(), a.end());
    for (int i = 0; i < m; i++)
    {
        cin >> b >> c;
        pairs.push_back(make_pair(c, b));
    }
    sort(pairs.begin(), pairs.end(), greater<pair<long, long>>());

    flag = false;
    d = 0;
    for (int i = 0; i < m; i++)
    {
        b = pairs[i].second;
        c = pairs[i].first;
        for (int j = 0; j < b; j++)
        {
            if (a[d] < c)
            {
                a[d] = c;
            }
            else
            {
                flag = true;
                break;
            }
            d++;
            if (d >= n)
            {
                flag = true;
                break;
            }
        }
        if (flag)
        {
            break;
        }
    }
    long sum = 0;
    for (int i = 0; i < n; i++)
    {
        sum += a[i];
    }

    cout << sum << endl;
}

Measured memory_bytes: 3188
import sys
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, chain
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp

#

class UnionFindEx:
    def __init__(self, size):
        #正なら根の番号、負ならグループサイズ
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   #負なら根
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    #サイズ更新
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'


def main():
    A,B=mis()
    print(A*B)



main()



Measured memory_bytes: 9988
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define str string
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define all(x) x.begin(),x.end()
int  main(){
  int N,K,B;
  str S1,S2,S3;
  cin>>N>>K;
  if(N+K>=10)cout<<"error"<<endl;
  else cout<<N+K<<endl;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
int main(){
        string s;
        int num;
        cin >> s;
        num = s.size();

        if(s[num - 1] == 's'){
                cout << s + "es" << endl;
        }else{
                cout << s + "s" << endl;
        }
        return 0;
}

Measured memory_bytes: 3632
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AABCSwap solver = new AABCSwap();
        solver.solve(1, in, out);
        out.close();
    }

    static class AABCSwap {
        public void solve(int testNumber, FastReader s, PrintWriter out) {
            int a = s.nextInt(), b = s.nextInt(), c = s.nextInt();
            out.println(c + " " + a + " " + b);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 21332
fun main(args: Array<String>) {
    val (N, Q) = readLine()!!.split(" ").map{it.toInt()}
    val S = readLine()!!

    val b = Array(S.length + 1) { 0L }
    for (i in 1 until S.length) {
        if (S.substring(i - 1, i + 1) == "AC") {
            b[i + 1] = 1
        }
        b[i + 1] += b[i]
    }

    for (i in 1..Q) {
        val (l, r) = readLine()!!.split(" ").map{it.toInt()}
        println(b[r] - b[l])
    }
}


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

int main(){
    int a,b;

    cin>>a>>b;
    
    if(a <= 0 && b >= 0){
        cout<<"Zero\n";
        return 0;
    }
    else if(a < 0 && (b - a + 1) % 2){
        cout<<"Negative\n";
        return 0;
    }

    cout<<"Positive\n";

}

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

vector<vector<int>> bitcnt;
int K;

vector<int> select(vector<int>& origin, int bit){
    if(bit == -1) return origin;
    int cnt = 0;
    vector<int> nextIdx;
    for(int i : origin){
        if(bitcnt[i][bit] == 1){
            nextIdx.push_back(i);
        }
    }

    if(nextIdx.size() < K)
        return select(origin, bit - 1);
    else
        return select(nextIdx, bit - 1);
}

int main(){
    int N;  cin >> N >> K;
    vector<ll> A(N+1, 0), sum(N+1, 0);
    for(int i=1; i<=N; i++){
        cin >> A[i];
        sum[i] += sum[i-1] + A[i];
    }

    vector<ll> B;
    for(int i=1; i<=N; i++) for(int j=i; j<=N; j++){
        B.push_back(sum[j] - sum[i-1]);
    }
    sort(B.begin(), B.end());
    int W = B.size();

    bitcnt.resize(W, vector<int>(61, 0));
    for(int i=0; i<W; i++){
        ll b = B[i];
        for(int k=0; k<61; k++){
            if(b%2==1){
                bitcnt[i][k]++;
            }
            b/=2;
        }
    }
    vector<int> idx(W);
    for(int i=0; i<W; i++)
        idx[i] = i;
    vector<int> selected = select(idx, 60);
    ll ans = -1;
    for(int i : selected){
        if(ans == -1) ans = B[i];
        else ans &= B[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 146800
import heapq
N = int(input())
V = list(map(int, input().split()))
heapq.heapify(V)

while len(V) >= 2:
    v1 = heapq.heappop(V)
    v2 = heapq.heappop(V)
    heapq.heappush(V, (v1+v2)/2)
print(V[0])


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if((a < c && c < b) || (b < c && c < a)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}


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

int main() {
    int r, c;
    std::cin >> r >> c;

    valarray<valarray<int>> matrix(valarray<int>(c), r);

    for (int i = 0; i < r; i++) {
        for (int j = 0; j < c; j++) {
            scanf("%d", &matrix[i][j]);
        }
    }

    for (int i = 0; i < r; i++) {
        for (int j = 0; j < c; j++) {
            std::cout << matrix[i][j] << " ";
        }
        std::cout << matrix[i].sum() << std::endl;
    }

    valarray<int> sum_row(c);
    for (int i = 0; i < r; i++) {
        sum_row += matrix[i];
    }
    for (int j = 0; j < c; j++) {
        std::cout << sum_row[j] << " ";
    }
    std::cout << sum_row.sum() << std::endl;
}



Measured memory_bytes: 3248
'use strict'

class Main {
  solve() {
    const nums = input.nextIntArr();
    const n = nums[0];
    const m = nums[1];
    const lines = input.nextIntArr();
    const table = input.nextIntRange(n);
    console.log(table.filter(line => line.reduce((a,b,i) => a + b * lines[i], nums[2]) > 0).length);
  }
}

class Input {
  constructor() {
	this.cursor = 0;
	this.inputAll();
  }

  inputAll() {
	this.data = (require("fs").readFileSync("/dev/stdin", "utf8")).split('\n');
	return this.data;
  }

  nextLine(n) {
	if (n) {
	  const ret = this.data.slice(this.cursor, this.cursor + n);
	  this.cursor += n;
	  return ret;
	}
	return this.data[this.cursor++];
  }

  nextStrArr() {
	return this.nextLine().split(' ');
  }

  nextIntArr() {
	return this.nextStrArr().map((e) => parseInt(e));
  }

  nextFloatArr() {
	return this.nextStrArr().map((e) => parseFloat(e));
  }

  nextIntLine(n) {
	return this.nextLine(n).map((e) => parseInt(e))
  }

  nextFloatLine(n) {
	return this.nextLine(n).map((e) => parseFloat(e))
  }

  nextStrRange(n) {
	return this.nextLine(n).map((line) => line.split(' '));
  }

  nextIntRange(n) {
	return this.nextLine(n).map((line) => line.split(' ').map((e) => parseInt(e)));
  }

  nextFloatRange(n) {
	return this.nextLine(n).map((line) => line.split(' ').map((e) => parseFloat(e)));
  }
}

const input = new Input();
(new Main()).solve();


Measured memory_bytes: 21192
import sys,heapq
from collections import deque,defaultdict
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True # and False
def ddprint(x):
  if DBG:
    print(x)

r,d,x = inm()
for i in range(10):
    x = r*x-d
    print(x)


Measured memory_bytes: 38384
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;

int main(){
    int ac=0,wa=0,tle=0,re=0;
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        if(s=="AC"){
            ac++;
        }else if(s=="WA"){
            wa++;
        }else if(s=="RE"){
            re++;
        }else if(s=="TLE"){
            tle++;
        }
    }
    cout<<"AC x "<<ac<<"\nWA x "<<wa<<"\nTLE x "<<tle<<"\nRE x "<<re<<endl;
    return 0;
}

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

int main(){
    int a,b,c,d;

    cin >> a >> b >> c >> d;

    if (a+b > c+d) {
        cout << "Left" << endl;
    }else if(a+b == c+d)
        cout << "Balanced" << endl;
    else
        cout << "Right" << endl;


}

Measured memory_bytes: 256
import sys

N = int(input())
p = [int(_) for _ in input().split()]

correct = [int(_) for _ in range(1,N+1)]

res = 0
if p == correct:
    res = 1
else:
    for i in range(N):
      for j in range(i+1,N):
        a = p[:]
        c = a[i]
        a[i] = a[j]
        a[j] = c
        if a == correct:
            res = 1

if res == 1:
    print('YES')
else:
    print('NO')

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

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

  vector<int> count(100);
  for (int i = 0; i < N; i++) {
    int d;
    cin >> d;

    count.at(d - 1)++;
  }

  int kagamimochi = N;
  for (int i = 0; i < count.size(); i++) {
    if (count.at(i) > 1) {
      kagamimochi -= count.at(i) - 1;
    } 
  }

  cout << kagamimochi << endl;
}

Measured memory_bytes: 3588
N,X = map(int,input().split())
def lb(N):
    if N != 0:
        return 2*lb(N-1)+3
    else:
        return 1
def pn(N):
    if N != 0:
        return 2*pn(N-1)+1
    else:
        return 1
def B(N,X):
    if X == 0:
        return 0
    elif N == 0:
      	return 1
    elif lb(N-1)+1 >= X:
        return B(N-1,X-1)
    else:
        return pn(N-1)+1+B(N-1,X-lb(N-1)-2)
print(B(N,X))


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

int main(){

  int n;
  cin >> n;
  map<int, int> m;
  for(int i=0; i<n; ++i){
    int v;
    cin >> v;
    if(m.find(v) == m.end()) m[v] = 1;
    else m[v]++;
  }

  int ans = 0;
  for(auto x: m){
    if(x.first > x.second) ans += x.second;
    else if (x.first < x.second) ans += (x.second - x.first);
  }

  cout << ans << endl;

}

Measured memory_bytes: 4736
#include <iostream>

using i64 = long long;

const int N = 3000 + 7;
const i64 MOD = 1000000007;
const i64 Inv2 = MOD - MOD / 2;

int n, q;
int a[N];
i64 f[N][N], g[N][N], ans, coe = 1;

int main() {
//	freopen("code.in", "r", stdin);
//	freopen("code.out", "w", stdout);

	scanf("%d%d", &n, &q);
	for (int i = 1; i <= n; ++i) scanf("%d", a + i);
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= n; ++j) f[i][j] = g[i][j] = a[i] > a[j];
	for (int x, y; q; --q) {
		scanf("%d%d", &x, &y);
		for (int i = 1; i <= n; ++i) {
			if (i != x) g[i][x] = (f[i][x] + f[i][y]) * Inv2 % MOD, g[x][i] = (f[x][i] + f[y][i]) * Inv2 % MOD;
			if (i != y) g[i][y] = (f[i][x] + f[i][y]) * Inv2 % MOD, g[y][i] = (f[x][i] + f[y][i]) * Inv2 % MOD;
		}
		g[x][y] = g[y][x] = (f[x][y] + f[y][x]) * Inv2 % MOD;
		for (int i = 1; i <= n; ++i)
			f[i][x] = g[i][x], f[x][i] = g[x][i], f[i][y] = g[i][y], f[y][i] = g[y][i];
		f[x][y] = f[y][x] = g[x][y];
		coe = coe * 2 % MOD;
	}
	for (int i = 1; i <= n; ++i)
		for (int j = i + 1; j <= n; ++j) ( ans += f[i][j] ) %= MOD;
	printf("%lld ", ans * coe % MOD);
	return 0;
}


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

int main() {
  string S;
  cin >> S;

  int year = stoi(S.substr(0, 4));
  int mon  = stoi(S.substr(5, 2));
  int day  = stoi(S.substr(8, 2));

  if (year <= 2019 && mon <= 4) {
    cout << "Heisei" << endl;
  } else {
    cout << "TBD" << endl;
  }
}

Measured memory_bytes: 256
n,m = map(int,input().split())

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

t.sort()
memo = []
for i in range(m-1):
    memo.append(t[i+1]-t[i])
memo.sort()
#print(memo)
ans = 0
for i in range(m-n):
    #print(i)
    ans += memo[i]
print(ans)

Measured memory_bytes: 56872
s = input()

# S = 晴，R = 雨
if(s.count('R') == 0):
    print(0)
elif(s.count('R') == 1):
    print(1)
elif(s.count('R') == 3):
    print(3)
else:
    if(s[1] == 'S'):
        print(1)
    else:
        print(2)

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

struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

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

signed main(){
    int n, m;
    cin >> n >> m;
    int t = 1900 * m + 100 * (n-m);
    int p = 1 << m;
    cout << t * p << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int l_total,l_ok;
	int d_total,d_ok;
	int m_total,m_ok;
	int t_h,t_m,zikan;
	int d_n,i;
	while(1) {
		scanf("%d",&d_n);
		if(d_n==0)break;
		l_total=l_ok=0;
		d_total=d_ok=0;
		m_total=m_ok=0;
		for(i=0;i<d_n;i++) {
			scanf("%d:%d%d",&t_h,&t_m,&zikan);
			if(t_h>=11 && t_h<15) {
				l_total++;
				zikan=(zikan+60-t_m)%60;
				if(zikan<=8)l_ok++;
			} else if(t_h>=18 && t_h<21) {
				d_total++;
				zikan=(zikan+60-t_m)%60;
				if(zikan<=8)d_ok++;
			} else if(t_h>=21 || t_h<2) {
				m_total++;
				zikan=(zikan+60-t_m)%60;
				if(zikan<=8)m_ok++;
			}
		}
		if(l_total>0)printf("lunch %d\n",l_ok*100/l_total);
		else puts("lunch no guest");
		if(d_total>0)printf("dinner %d\n",d_ok*100/d_total);
		else puts("dinner no guest");
		if(m_total>0)printf("midnight %d\n",m_ok*100/m_total);
		else puts("midnight no guest");
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.*;
import java.math.*;

public class Main {
    static final int MOD = 1_000_000_007; // 10^9+7
    // static final int MAX = 2_147_483_646; // intの最大値
    static final int INF = 1_000_000_000; // 10^9
    static final int MAX = 10_000_000;

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] ary = new int[n];
        for(int i = 0;i < n-1;i++){
            ary[sc.nextInt()-1]++;
        }
        for(int i = 0;i < n;i++){
            System.out.println(ary[i]);
        }
        

    }

}


Measured memory_bytes: 62204
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

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



int main(){
  lll ii,jj,kk;
  lll n,k;
  cin >> n >> k;
  vector<lll> a,a2,num,num2;
  const lll mod = 1000000007;
  a.resize(n);
  a2.resize(n*2);

  num.resize(n);
  num2.resize(n);
  
  for(ii=0;ii<n;ii++){
    cin >> a[ii];
  }
  
  for(ii=0;ii<n*2;ii++){
    a2[ii] = a[ii%n];
  }
  lll ans1,ans2;
  ans1 = 0;
  ans2 = 0;
  for(ii=0;ii<n-1;ii++){
    for(jj=ii+1;jj<n;jj++){
      if(a[ii] > a[jj]){
        num[ii]++;
      }
    }
  }

  for(ii=0;ii<n;ii++){
    for(jj=0;jj<n;jj++){
      if(a2[ii] > a2[jj]){
        num2[ii]++;
      }
    }
  }

  //for(ii=0;ii<n;ii++){
  //  cout << "num:" << num[ii] << "num2:" << num2[ii] << endl;
  //}
  lll sum = 0;

  lll tmp;
  for(ii=0;ii<n;ii++){
    sum += (num[ii] * k) % mod;
  }
  
  for(ii=0;ii<n;ii++){
    tmp = (num2[ii] * ((k*(k-1)/2) % mod)) % mod;
    //cout << "tmp:" << tmp << endl;
    sum = (sum + tmp) %  mod;
    //cout << "sum:" << sum << endl;
  }

  //for(ii=0;ii<n;ii++){
  //  sum += num2[ii];
  //}
  
  cout << sum << endl;
  //cout << ((ans1*k) + (((k*(k-1)/2%mod*ans2))))%mod << endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define RFOR(i, s, n) for (int i = (n) - 1; i >= (s); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(a) a.begin(), a.end()
const long long MOD = 1e9+7, INF = 1e18;
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a=b;return true;}return false;}



signed main(){
	string s;
	cin>>s;
	int ans = 0;
	string now="",to="";
	REP(i,(int)s.size()){
		now+=s[i];
		if(now!=to){
			to=now;
			now="";
			ans++;
		}
	}
	cout<<ans<<endl;
}


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

int main(){
	int k;
	cin>>k;
	int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	cout<<a[k-1];
	
}

Measured memory_bytes: 256
MOD = 10**9 + 7

class Combination:
    def __init__(self, size):
        self.size = size + 2
        self.fact = [1, 1] + [0] * size
        self.factInv = [1, 1] + [0] * size
        self.inv = [0, 1] + [0] * size

        for i in range(2, self.size):
            self.fact[i] = self.fact[i - 1] * i % MOD
            self.inv[i] = -self.inv[MOD % i] * (MOD // i) % MOD
            self.factInv[i] = self.factInv[i - 1] * self.inv[i] % MOD

    def npr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * self.factInv[n - r] % MOD

    def ncr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * (self.factInv[r] * self.factInv[n - r] % MOD) % MOD

    def nhr(self, n, r):  # 重複組合せ: x_1 + ... + x_n = r
        return self.ncr(n + r - 1, n - 1)

N, K = map(int, input().split())
K = min(K, N)
MOD = 10**9 + 7
comb = Combination(N + 100)

ans = 0
for k in range(K + 1):
    ans += comb.ncr(N, k) * comb.nhr(N - k, k)
    ans %= MOD

print(ans)


Measured memory_bytes: 28336
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    int n;
    scanf("%d", &n);
    int nx = 0, ny = 0, nt = 0;
    bool ok = true;
    REP(i, n) {
        int x, y, t;
        scanf("%d%d%d", &t, &x, &y);
        int dist = abs(nx - x) + abs(ny - y);
        if (dist > t - nt) {
            ok = false;
        } else if (((t - nt) - dist) % 2) {
            ok = false;
        }
        nx = x, ny = y, nt = t;
    }
    cout << (ok ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
using namespace std;

int main(){
	int N;
	cin>>N;
	cin.ignore();
	while(N--){
		char S[1001];
		for(int i=0;;i++){
			scanf("%c",&S[i]);
			if(S[i]=='\n'){
				S[i] = '\0'; break;
			}
		}
		int len = strlen(S);
		for(int i=0;i<len;i++){
			if(strncmp(S+i,"Hoshino",7)==0){
				printf("Hoshina"); i += 6;
			}
			else printf("%c",S[i]);
		}puts("");
	}
    return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;



int main(){
    ll A, B, C, K;
    cin>>A>>B>>C>>K;
    ll Sum=0;
    ll Zan=K;
    if(Zan<=A){
        cout<<K<<endl;
        return 0;
    }
    Sum=A;
    Zan-=A;
    if(Zan<=B){
        cout<<Sum<<endl;
        return 0;
    }
    Zan-=B;
    cout<<Sum-(Zan)<<endl;
    return 0;
}

Measured memory_bytes: 3568
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val S = next()
    println("2018" + S.drop(4))
}

Measured memory_bytes: 31880
def solve(string):
    n, *l = map(int, string.split())
    l.sort()
    nums = 0
    for i, a in enumerate(l[:-2]):
        k = i + 2
        for j, b in enumerate(l[i + 1:-1], i + 1):
            while k < n and l[k] < a + b:
                k += 1
            nums += k - j - 1
    return str(nums)


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))


Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int K = scanner.nextInt();

        System.out.println(consecutive(N, K));;
    }

    protected static int consecutive(int N, int K) {
        int consecutive = N-K+1;

        return consecutive;
    }
}

Measured memory_bytes: 21716
#include <stdio.h>
int F[50];

int fib(int n){
    if(n==0||n==1) return F[n]=1;
    else if(F[n]!=-1) return F[n];
    else return F[n]=fib(n-1)+fib(n-2);
}
int main(void){
    int n, i;
    for(i=0;i<50;i++) F[i]=-1;
    
    scanf("%d", &n);
    printf("%d\n",fib(n));
    
    return 0;
}


Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll;
int main(){
   //  #ifndef ONLINE_JUDGE
   //      freopen("input.txt","r",stdin);
   //      freopen("output.txt","w",stdout);
   // #endif
	// ios::sync_with_stdio(false);
	// cin.tie(0);
	ll n,sum=0;
    cin>>n;string s;
    cin>>s;
    for(ll i=0;i<=n-3;i++)
    {
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')
        sum++;
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  string s,t;
  cin>>s>>t;
  int n = s.size();
  rep(__i,n) {
    stringstream ss;
    ss<<s[n-1];
    rep(i,n-1) ss<<s[i];
    s=ss.str();
    if(s==t) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,ix,i,ans
    integer(int32), allocatable:: x(:),dx(:)

    read*, n,ix
    allocate(x(n+1))
    x(1) = ix
    read*, x(2:)
    
    call merge_sort(x,1,n+1)
    
    allocate(dx(n))
    do i=1,n
        dx(i) = x(i+1)-x(i)
    end do
    deallocate(x)
    ans=dx(1)
    do i=2,n
        ans=gcd(ans,dx(i))
    end do

    print'(i0)', ans
contains
recursive function gcd(x,y) result(ret)
    integer(int32):: x,y,ret

    if (mod(x,y) == 0) then
        ret = y
        return
    end if
    
    ret = gcd(y,mod(x,y))
end function
recursive subroutine merge_sort(ar, fst, lst)
integer(int32),intent(inout):: ar(:)
integer(int32),intent(in):: fst,lst
integer(int32):: mdl

if (lst-fst < 2) then
    if (ar(fst) > ar(lst)) call swap(ar(fst),ar(lst))
    return
end if

mdl = (fst+lst)/2
call merge_sort(ar, fst, mdl)
call merge_sort(ar, mdl+1, lst)
call merge_(ar, fst, mdl, lst)
end subroutine

subroutine merge_(ar, fst, mdl, lst)
integer(int32),intent(inout):: ar(:)
integer(int32),intent(in):: fst, mdl, lst
integer(int32),allocatable:: tmp(:)
integer(int32):: li, ri, ti

allocate(tmp(lst-fst+1))

li=fst
ri=mdl+1   
ti=1

do while (li <= mdl .and. ri <= lst)
    if (ar(li) <= ar(ri)) then
        tmp(ti) = ar(li)
        li=li+1
    else
        tmp(ti) = ar(ri)
        ri=ri+1
    end if
    ti=ti+1
end do

if (li <= mdl) then
    tmp(ti:) = ar(li:mdl)
else
    tmp(ti:) = ar(ri:lst)
end if

ar(fst:lst) = tmp(:)
deallocate(tmp)
end subroutine

subroutine swap(x,y)
integer(int32),intent(inout):: x,y
integer(int32):: tmp
tmp = x
x = y
y = tmp
end subroutine
end program name

Measured memory_bytes: 1724
#include<bits/stdc++.h>
#define int long long int  //comment for large arrays
#define pll pair<int,int>
#define dbl long double
#define ff first
#define ss second
#define endl "\n"
#define mod 1000000007
#define eps 0.00000001
#define INF 10000000000000001
#define all(x) (x).begin(),(x).end()
#define LB(v,x) (lower_bound(all(v),x) - v.begin()) 
#define UB(v,x) (upper_bound(all(v),x) - v.begin())
#define size(x) (int)(x).size()
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define popb() pop_back()
#define popf() pop_front()
#define mp(x,y) make_pair((x),(y))
#define vec(dt) vector<dt>
#define vv(dt) vector<vector<dt>>
#define fastio(x) ios_base::sync_with_stdio(x); cin.tie(NULL)
#define init(v,s) memset(v,s,sizeof(v)) 
#define bug(x) cerr<<"LINE: "<<__LINE__<<" || click to see test details "<<#x<<" = "<<x<<endl
#define loop(i,s,n) for(int i=s;i<n;i++)
#define print(v) for(auto it:v) cout<<it<<" "; cout<<endl 
using namespace std;


signed main()
{
	fastio(0);
	int n,k;
	cin>>n>>k;
	int a[n+1],dp[k+1];
	loop(i,1,n+1) cin>>a[i];
	init(dp,0);
	loop(i,0,k+1) if(i<=a[1]) dp[i] = 1;
	loop(i,2,n+1)
	{
		loop(j,1,k+1) dp[j] = (dp[j] + dp[j-1])%mod;
		for(int j=k;j>0;j--)
			if(j>a[i]) 
				dp[j] = (dp[j] - dp[j-a[i]-1] + mod)%mod;
	}
	cout<<dp[k]%mod<<endl;
	return 0;		
}

Measured memory_bytes: 1024
object Main extends App {
  import scala.io.StdIn._
  val Array(n, r) = readLine.trim.split(' ').map(_.toInt)
  val numbers = readLine.trim.split(' ').map(_.toInt - 1)
  val uft = new UnionFind(n + 1)
  for (i ← numbers.indices) {
    uft.merge(i, numbers(i))
  }
  var size = Nil: List[Int]
  for (i ← numbers.indices if !uft.isSame(i, n)) {
    size ::= uft.sizeOf(i)
    uft.merge(i, n)
  }
  val values = size.groupBy(identity).mapValues(_.length).toArray.sortBy(_._1)
  val memo = Array.fill(math.min(n - r, r) + 1){false}
  memo(0) = true
  for ((v, c) ← values) {
    var i = 0
    while ((1 << (i + 1)) <= c) {
      val value = v << i
      for (j ← (0 until memo.length - value).reverse if memo(j)) {
        memo(j + value) = true
      }
      i += 1
    }
    val rest = c - (1 << i) + 1
    val value = rest * v
    if (rest != 0) for (j ← (0 until memo.length - value).reverse if memo(j)) {
      memo(j + value) = true
    }
  }
  println(
    if (memo.last) "Yes" else "No"
  )
}
class UnionFind(val size: Int) {
  private[this] val parent = Array.fill(size){-1}
  def find(a: Int): Int = {
    if (parent(a) < 0) a
    else {
      parent(a) = find(parent(a))
      parent(a)
    }
  }
  def isSame(a: Int, b: Int): Boolean = find(a) == find(b)
  def merge(a: Int, b: Int): Unit = {
    val ar = find(a)
    val br = find(b)
    if (ar != br){
      if (parent(ar) < parent(br)) {
        parent(ar) += parent(br)
        parent(br) = ar
      }else {
        parent(br) += parent(ar)
        parent(ar) = br
      }
    }
  }
  def sizeOf(a: Int): Int = -parent(find(a))
}


Measured memory_bytes: 445304
n=int(input())
rates=list(map(int,input().split()))

c=[0,0,0,0,0,0,0,0]
cnt=0
for rate in rates:
  for i in range(8):
    if 400*i<=rate<400*(i+1):
      c[i]+=1
      break
  if rate>=3200:
    cnt+=1
    
ans=len(c)-c.count(0)
if ans==0:
  ans=1
print(min(n,ans),min(n,ans+cnt))

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <iterator>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <numeric>

#define YESNO(x) x ? printf("YES") : printf("NO")
#define YesNo(x) x ? printf("Yes") : printf("No")
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define scani(x) scanf("%d", &x)
#define scanll(x) scanf("%lld", &x)
#define printi(x) printf("%d", x)
#define printll(x) printf("%lld", x)
typedef long long ll;
using namespace std;

long long GCD(long long x, long long y) {
	return y ? GCD(y, x % y) : x;
}

long long LCM(long long x, long long y) {
	return x * y / GCD(x, y);
}

int A() {
	int n;

	scani(n);

	YesNo(7 == n % 10 || 7 == n / 10 % 10 || 7 == n / 100);


	return 0;
}

int Main() {
	int n;

	scani(n);

	long long ans = 0;
	for (int i = 1; i <= n; i++) {
		if (i % 3 && i % 5) {
			ans += i;
		}
	}

	printll(ans);

	return 0;
}

int main()
{
	Main();
	return 0;
}


Measured memory_bytes: 3828
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>

using namespace std;

int main(){
  int P,Q,R;
  cin >> P >> Q >> R;
  int tmp = max({P,Q,R});
  cout << P + Q + R - tmp << endl;
}


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

using namespace std;

#define fi first
#define se second

const int N = 3003;
char s[N], t[N], res[N];
int dp[N][N];
pair <int, int> par[N][N];

int main() {
	s[0] = t[0] = '.';
	scanf("%s\n%s", s + 1, t + 1);
	int n = strlen(s), m = strlen(t);
	for (int i = 1; i < n; i++) {
		for (int j = 1; j < m; j++) {
			int mx = -1e9;
			if (dp[i][j-1] > mx) {
				mx = dp[i][j-1];
				par[i][j] = {i, j - 1};
			}
			if (dp[i-1][j] > mx) {
				mx = dp[i-1][j];
				par[i][j] = {i - 1, j};
			}
			if (dp[i-1][j-1] + (s[i] == t[j]) > mx) {
				mx = dp[i-1][j-1] + (s[i] == t[j]);
				par[i][j] = {i - 1, j - 1};
			}
			dp[i][j] = mx;
		}
	}
	//printf("%d\n", dp[n-1][m-1]);
	--n;
	--m;
	int cnt = 0;
	while (n != 0 && m != 0) {
		if (par[n][m].fi != n && par[n][m].se != m) {
			res[cnt++] = s[n];
		}
		int hold = n;
		n = par[n][m].fi;
		m = par[hold][m].se;
	}
	reverse(res, res + cnt);
	printf("%s", res);
	return 0;
}


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

int main() {
    while(1) {
        int a, b;
        char op;
        cin >> a >> op >> b;
        
        if(op == '+') {
            cout << a + b << endl;
        } else if(op == '-') {
            cout << a - b << endl;
        } else if(op == '*') {
            cout << a * b << endl;
        } else if(op == '/') {
            cout << a / b << endl;
        } else if(op == '?') {
            return 0;
        }
    }
}


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

int main(){
  int A,B,C,D;
  cin >>A>>B>>C>>D;
  if((A+D-1)/D>=(C+B-1)/B){
  cout<<"Yes"<<endl;
  }
  if((A+D-1)/D<(C+B-1)/B){
  cout<<"No"<<endl;
  }
}


Measured memory_bytes: 3620
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<ld> vld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)


int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<ll> A(N), B(N), S(N);;
    for (int n = 0; n < N; ++n) {
        cin >> A[n] >> B[n];
        S[n] = A[n] + B[n];
    }
    vector<int> vi(N);
    for (int n = 0; n < N; ++n) {
        vi[n] = n;
    }
    sort(vi.begin(), vi.end(), [&S](int l, int r){return S[l] > S[r];});
    ll res = 0;
    for (int n = 0; n < N; ++n) {
        if (n&1) {
            res -= B[vi[n]];
        } else {
            res += A[vi[n]];
        }
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int n;
vector<int> a;
vector<int> b;
ll md = 998244353;

int rs() {
    if (a[0]) return 0;
    b.assign(n + 1, 0);
    for (int i = 0; i < n; i++)
        b[a[i]]++;
    if (b[0] - 1) return 0;
    ll res = 1;
    int sum = 0;
    for (int i = 0; i < n && b[i]; i++) {
        sum += b[i];
        for (int j = 0; j < b[i + 1]; j++) {
            res *= b[i];
            res %= md;
        }
    }
    if (sum < n) return 0;
    
    return res;

}
int main() {
    cin >> n;
    a.assign(n, 0);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    cout << rs() << endl;
    return 0;
}


Measured memory_bytes: 1024