akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define pb           push_back
#define pii          pair<int,int>
#define vi           vector<int>
#define vpii         vector<pair<int,int>>
#define gph          map<int, vector<int>>
#define mp           make_pair
#define FOR(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD0(i, n) for (int i = (int)n; i >= 0; i--)
#define FORD1(i, n) for (int i = (int)n; i >= 1; i--)
#define FORS(i, n) for(; i < (int)(n); i++)
#define debug(X) { cout << #X << " = " << (X) << endl; }
#define printArr(A,n) { cout << #A << " = "; FOR(i,n) cout << A[i] << ' '; cout << endl; }
using namespace std;


signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    
    int n;cin >> n;
    map<int, int> cnt;
    int in;
    FOR(i, n){
        cin >> in;
        cnt[in]++;
    }
    vi temp;
    for(pii tem:cnt)temp.pb(tem.second);
    sort(temp.begin(), temp.end(), greater<int>());
    vector<int> pre(n+1);
    FORD0(i, temp.size() -1){
       pre[i] = pre[i+1] + temp[i];
      // cout <<i << " " << pre[i] <<endl;
    }
    int tot = n;
    int loc = 0;
    int ans = n;
    FOR1(i, n){
        while(ans != (loc * ans + pre[loc])/i){
            ans = (loc*ans + pre[loc])/i;
        }
        if(i > temp.size()){
            cout << 0 <<endl;
            continue;
        }
        while(loc < temp.size() && ans < temp[loc]){
            loc++; 
            while(ans != (loc* ans + pre[loc])/i){
                ans = (loc*ans + pre[loc])/i;
            }
        }
        //        debug(loc);
        cout << ans <<endl;
    }

}




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

typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;

const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);

#define FOR(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RFOR(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define ull unsigned long long
#define deb(x )     cerr << #x << " = "<< x << endl;
#define endl    "\n"
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define fill(x, y) memset(x, y, sizeof(y))
#define all(x) (x).begin(), (x).end()
#define bitcount(x) __builtin_popcount(x)
#define cps CLOCKS_PER_SEC
#define verify(x) if(x >= MOD) x -= MOD;

inline void debug_vi(vi a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void debug_vll(vll a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void print_case(int tn) {cout<<"Case #"<<tn<<": ";}

template<typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;

template<typename T>
using maxpq = priority_queue<T>;
/*----------------------------------------------------------------------*/

int main(){
    std::ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    int n; cin>>n;
    vi arr(n + 1, 1);
    ll res = 0;
    FOR(i, 2, n + 1) {
        for(int j = i; j <= n; j += i) {
            arr[j]++;
        }
    }
    FOR(i, 1, n + 1) {
        res += i * 1LL * arr[i];
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 42264
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <cstdlib>
#include <cctype>
#define ll long long
#define PI 3.14159265358979323846
using namespace std;

int main(){
	int a[7]={1,3,5,7,8,10,12};
	int b[4]={4,6,9,11};
	int c=2;
	int x,y;
	int fax=0,fay=0,fbx=0,fby=0;
	cin>>x>>y;
	if(x==2||y==2){
		cout<<"No"<<endl;
		return 0;
	}
	for(int i=0;i<7;i++){
		if(a[i]==x){
			fax=1;
		}
		else if(a[i]==y){
			fay=1;
		}
	}
	for(int i=0;i<4;i++){
		if(b[i]==x){
			fbx=1;
		}
		else if(b[i]==y){
			fby=1;
		}
	}
	if(fax==1&&fay==1||fbx==1&&fby==1){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
q = int(input())

p=1000003

flist=[1 for i in range(p)]
for i in range(1,p):
    flist[i]=flist[i-1]*i%p

for i in range(q):
  x,d,n=(int(i) for i in input().split())
  if d==0:
    ans=pow(x,n,p)
  else:
    x=x*pow(d,p-2,p)%p    
    if p<=x+n-1:
      ans=0
    else:
      ans=pow(d,n,p)*flist[x+n-1]*pow(flist[x-1],p-2,p)%p
  print(ans%p)

Measured memory_bytes: 114288
import java.util.*;
import java.io.*;
class Main{

     public static void main(String []args){
        Scanner sc=new Scanner(System.in);
         int n=sc.nextInt();
         int w=sc.nextInt();
         int wi[]=new int[n];
         int v[]=new int [n];
         
          for(int i=0;i<n;i++)
          {
              wi[i]=sc.nextInt();
              v[i]=sc.nextInt();
          }
          
         long dp[][]=new long[n][w+1];
         
         for(int i=wi[0];i<=w;i++)
          {
              dp[0][i]=v[0];
          }
          for(int i=1;i<n;i++)
           {
             for(int j=0;j<=w;j++)
              {
                 
                 if(j<wi[i])
                  dp[i][j]=dp[i-1][j];
                  else
                  dp[i][j]=Math.max(dp[i-1][j] , v[i]+dp[i-1][j-wi[i]]);
               }
               
          }
         
         System.out.println(dp[n-1][w]);
            
             
           
          
       }
     
     
}

Measured memory_bytes: 126548
def f(a,b):
  p,q=a,b
  while q!=0: p,q=q,p%q
  return a/p*b

def g(a,b):
  c,i=a%b,1
  while c!=1: i,c=i+1,(c*a)%b
  return i
  
while 1:
  x=map(int,raw_input().split())
  if any(x)==0: break
  a,b,c=[g(x[i],x[i+1]) for i in range(0,6,2)]
  print f(f(a,b),c)

Measured memory_bytes: 4224
def Split(a):
    no = []
    for i, x in a:
        if no and (i == x) == (no[-1][0] == no[-1][1]):
            yield no
            no = []
        no.append((i, x))
    yield no

for sq in Split((i + 1, int(input())) for i in range(int(input()))):
    tb = [0, 0]
    for np, goal in sq:
        if goal != np:
            if goal < tb[np < goal] or goal > sq[-1][0] or goal < sq[0][0]:
                print("No")
                exit(0)
            tb[np < goal] = goal
print("Yes")

Measured memory_bytes: 43564
#include<bits/stdc++.h>
using namespace std;
unordered_map<int, int> cache;
int solve(vector<int>& heights, int index, int k) {
	int n = heights.size();
	if (index >= n - 1) {
		return 0;
	}

	if (cache.find(index) != cache.end()) {
		return cache[index];
	}

	int ans = INT_MAX;

	for (int i = index + 1; i <= min(index + k, n - 1); i++) {
		ans = min(ans, abs(heights[i] - heights[index]) + solve(heights, i, k));
	}

	return cache[index] = ans;
}

int main() {
	int n, x, k;
	cin>> n>>k;
	vector<int> heights;
	for (int i = 0; i < n; i++) {
		cin>>x;
		heights.push_back(x);
	}
	cout<<solve(heights, 0, k)<<endl;
}

Measured memory_bytes: 15560
#include <stdio.h>
int main(){
  int n,q,i,j,k;
  int a[2000]={0};
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&q);
    for(j=2000-q;j>0;j--){
      if(a[j]){
        a[j+q] = 1;
      }
    }
    a[q] = 1;
  }
  scanf("%d",&k);
  for(i = 0; i < k; i++){
    scanf("%d", &q);
    if(a[q]){
      printf("yes\n");
    }
    else printf("no\n");
  }
  
  return 0;
}

Measured memory_bytes: 588
using System;
using System.Linq;

namespace atcoderTest
{
    public class Program
    {
		public static void Main(string[] args)
		{

			// 文字列の入力
			var tes = Console.ReadLine();
			string[] a = tes.Split(' ');

			var basenumber = Convert.ToDecimal(a[0]);
			var bluenumver = Convert.ToDecimal(a[1]);
			var rednumber = Convert.ToDecimal(a[2]);

			var calc = bluenumver + rednumber;

			// 青のボールが0この場合は終わり
			if (!Convert.ToBoolean(bluenumver))
			{
				Console.WriteLine(0);
				return;
			}

			var basewari = Math.Truncate(basenumber / calc);

			// 合算
			var sum = bluenumver * basewari;
			// あまり
			var amari = basenumber % calc;

			// 余りが青よりも大きければそのままタス
			if (amari > bluenumver)
			{
				Console.WriteLine(sum + bluenumver);
			}
			else
			{
				Console.WriteLine(sum + amari);
			}


		}
	}
}


Measured memory_bytes: 13268
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

template <typename T>
void print_vec(const vector<T>& v, bool is_reverse=false, ll num=0){
  if(num == 0) num = (ll)v.size();
  cout << endl; cout << "i=  ";for(ll i=0; i<num; i++) cout << i << "   ";cout << endl;  
  cout << "    ";
  if(is_reverse) for(ll i=num-1; i>=0; i--){ cout<<v[i]; if(i!=0) cout<<"   ";}
  else for(ll i=0; i<num; i++){ cout<<v[i]; if(i!=num-1) cout<<"   ";}
  cout << endl;
}

// template <typename T>
// void print_pairvec(const vector<T> &v, ll num=0){
//   if(num == 0) num = (ll)v.size();
//   cout << endl; for(ll i=0; i<num; i++){ cout << v[i].first << " " << v[i].second << endl;}
// }
template <typename T>
void print_pairvec(const T &_pair, ll num=0){
  cout << endl; for(pair<ll, int> x: _pair){ cout << x.first << " " << x.second << endl;}
}

template <typename T>
void print_vec2(const vector<vector<T>>& v){
  cout << endl; cout << "       ";
  for(ll i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(ll i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(ll j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}

int chmax(int &a, int b){ return a = max(a, b);}
int main(){
  int N, K;
  cin >> N >> K;
  vector<int> V(N);
  for(int i=0; i<N; i++) cin >> V[i];

  int ans = 0;
  for(int left=0; left<=N; left++){
    for(int right=0; right<=N-left; right++){
      int tmp_k = K - left - right;
      if(tmp_k < 0) continue;
      priority_queue<int, vector<int>, greater<int>> get; 
      for(int i=0; i<left; i++) get.push(V[i]);
      for(int i=0; i<right; i++) get.push(V[N-i-1]);
      for(int i=0; i<tmp_k; i++){
        if(!get.empty() && get.top() < 0) get.pop();
        else break;
      }
      int sum = 0;
      while(!get.empty()){ sum += get.top(); get.pop(); }
      // cout << " left: " << left << " right: " << right << " sum: " << sum << " ans: " << ans << endl;
      ans = max(ans, sum);
    }
  }
  cout << ans << endl;
  return 0;
}


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

const int MAXN = 1e5+10;
int dp[30][MAXN],x[MAXN],l,n;
int q;

int main()
{
    int i,j;
    cin >> n;
    for(int i = 1; i <= n; ++i)
        cin >> x[i];
    cin >> l;
    for(int i = 1; i < n; ++i)
        dp[0][i] = upper_bound(x+1,x+n+1,x[i]+l) - x - 1;
    for(i = 1; i < 17; ++i)
    {
        for(j = 1; j <= n; ++j)
            dp[i][j] = dp[i-1][dp[i-1][j]];
    }
    cin >> q;
    int a,b,res;
    while(q--)
    {
        res = 0;
        cin >> a >> b;
        if(a > b) swap(a,b);
        for(i = 17; i >= 0; --i)
        {
            if(dp[i][a] == 0) continue;
            if(dp[i][a] < b)
            {
                a = dp[i][a];
                res += (1<<i);
            }
            else if(dp[i][a] == b)
            {
                i--;
                break;
            }
        }
        res += 1<<(i+1);
        cout << res << endl;
    }
    return 0;
}


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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    char x,y;
    cin>>x>>y;
    if (x==y) cout<<'='<<endl;
    else if (x<y) cout<<'<'<<endl;
    else cout<<'>'<<endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 1
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	ans := 0
	for i := 1; i <= n; i += 2 {
		sum := 0
		for j := 2; j*j <= i; j++ {
			if i%j != 0 {
				continue
			}
			sum += 2
			if j*j == i {
				sum--
			}
		}
		if sum == 6 {
			ans++
		}

	}

	fmt.Fprintln(writer, ans)
}


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

int main() {
  int N;
  cin >> N;
  map<int, int> dmp;
  int D;
  rep(i, N) {
    cin >> D;
    dmp[D]++;
  }

  int M;
  cin >> M;
  map<int, int> tmp;
  int T;
  rep(i, M) {
    cin >> T;
    tmp[T]++;
  }

  for (auto x : tmp) {
    if (x.second > dmp[x.first]) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 22324
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim_end().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim_end().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let n: i8 = read();
    let mut count = 0;
    for _ in 0..n {
        let di: Vec<u8> = read_vec();
        if di[0] == di[1] {
            count += 1;
        } else {
            count = 0;
        }
        if 3 <= count {
            println!("Yes");
            return
        }
    }
    println!("No");
}


Measured memory_bytes: 2168
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n;i>=0;i--)
#define For(i,m,n) for(int i=m;i<n;i++)
#define Forr(i,m,n) for(int i=m;i>n;i--)
#define Sort(a) sort(a.begin(),a.end())
#define pb push_back
#define vl vector<ll>
#define vll vector<vector<ll>>
#define INF 99999999

int main(){
  int N,A[21]={0},B[21]={0},C[21]={0},sat=0,memo=INF;
  cin>>N;
  rep(i,N){
    cin>>A[i+1];
  }
  rep(i,N){
    cin>>B[A[i+1]];
  }
  rep(i,N-1){
    cin>>C[i+1];
  }
  rep(i,N){
    sat+=B[A[i+1]];
    if(A[i+1]==memo+1) sat+=C[memo];
    memo=A[i+1];
  }
  cout<<sat<<endl;
  return 0;
}


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

int main(){
  int n, k;
  cin >> n >> k;
  int a[n];
  rep(i,n) cin >> a[i];
  sort(a,a+n);
  int l = -1, r = n;
  while(r - l > 1) {
    int m = (l + r) / 2;
    bool can = false;
    vector<vector<bool>> v(n+1,vector<bool>(k,false));
    v[0][0] = true;
    rep(i,n) {
      rep(j,k) {
        if(v[i][j]) {
          v[i+1][j] = true;
          if(i != m && j + a[i] < k) v[i+1][j+a[i]] = true;
        }
      }
    }
    for(int i = max(0,k-a[m]); i < k; i++) {
      if(v[n][i]) can = true;
    }
    can ? r = m : l = m;
  }
  cout << l + 1 << endl;
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
const int INF = 1000000007;

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

int N;
vector<int> march(5, 0);
ll ans = 0;

void dfs(vector<int> &A){
    if(A.size() == 3){
        ll tmp = 1;
        for(int i : A){
            tmp *= march[i];
        }
        ans += tmp;
        return;
    }

    int a;
    if(A.size() == 0) a = 0;
    else a = A.back() + 1;

    while(a <= 4){
        A.push_back(a);
        dfs(A);
        A.pop_back();
        a++;
    }
}


int main(){
    cin >> N;
    rep(i, N){
        string s;
        cin >> s;
        if(s[0] == 'M') march[0]++;
        else if(s[0] == 'A') march[1]++;
        else if(s[0] == 'R') march[2]++;
        else if(s[0] == 'C') march[3]++;
        else if(s[0] == 'H') march[4]++;
    }

    vector<int> A(0);
    dfs(A);

    cout << ans << endl;

}

Measured memory_bytes: 256
X,Y = input().split()
def Toint(string):
    if string == "A":
        return 10
    elif string == "B":
        return 11
    elif string == "C":
        return 12
    elif string == "D":
        return 13
    elif string == "E":
        return 14
    elif string =="F":
        return 15
    else:
        return int(string)
if Toint(X) < Toint(Y):
    print("<")
elif Toint(X) > Toint(Y):
    print(">")
else:
    print("=")

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>

int main() {
    int A, B, K;
    std::cin >> A >> B >> K;
    
    if ((B-A+1) <= K*2) {
        for (int i=A; i<=B; i++)
            std::cout << i << std::endl;
    } else {
        for (int i=A; i<A+K; ++i) {
            std::cout << i << std::endl;
        }
        for (int i=B-K+1; i<=B; ++i) {
            std::cout << i << std::endl;
        }
    }
}

Measured memory_bytes: 256
let max (x : int) y = if x > y then x else y

let lcs (x, y) =
  let m = String.length x in
  let n = String.length y in
  let s = Array.make (n + 1) 0 in
  let t = Array.copy s in
  for i = 1 to m do
    for j = 1 to n do
      t.(j) <- if x.[i-1] = y.[j-1] then s.(j-1) + 1 else max s.(j) t.(j-1)
    done;
    Array.iteri (fun i e -> s.(i) <- e) t;
  done;
  t.(n)

let () =
  let q = Scanf.scanf "%d " (fun q -> q) in
  for _ = 0 to q - 1 do
    Scanf.scanf "%s %s " (fun x y -> x, y)
    |> lcs
    |> Printf.printf "%d\n"
  done

Measured memory_bytes: 3548
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	static void solve(){//Here is the main function
		String[] alpha = "abcdefghijklmnopqrstuvwxyz".toUpperCase().split("");
		ArrayList<Integer> one = nextIntArray();
		int H = one.get(0);
		int W = one.get(1);
		for(int i = 0; i < H; i++){
			ArrayList<String> s = nextStrArray();
			if(s.indexOf("snuke") != -1){
				myout(alpha[s.indexOf("snuke")] + String.valueOf((i + 1)));
			}
		}
	}
	//Method addition frame start



	//Method addition frame end

	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
}


Measured memory_bytes: 37664
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<n; i++)
template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

long long dp[3003][3003];
bool vis[3003][3003];
vector<long long> a;

long long func(int x, int y, int turn){
    if(x > y) return 0;
    if(vis[x][y]) return dp[x][y];
    vis[x][y] = true;
    if(turn == 0){
        long long s0 = a[x] + func(x+1, y, 1);
        long long s1 = a[y] + func(x, y-1, 1);
        if(s0 > s1){
            dp[x][y] = s0;
            return dp[x][y];
        }else{
            dp[x][y] = s1;
            return dp[x][y];
        }
    }else{
        long long s0 = -a[x] + func(x+1, y, 0);
        long long s1 = -a[y] + func(x, y-1, 0);
        if(s0 < s1){
            dp[x][y] = s0;
            return dp[x][y];
        }else{
            dp[x][y] = s1;
            return dp[x][y];
        }
    }
}

int main(){
    int N;
    cin >> N;
    a.resize(N);
    REP(i, N) cin >> a[i];
    cout << func(0, N-1, 0) << endl;
    return 0;
}

Measured memory_bytes: 78464
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x, y;
  cin >> x >> y;
  if(y > 4*x) {
    cout << "No" << endl;
  } else if(y < 2*x) {
    cout << "No" << endl;
  } else {
    if(y%2 == 0) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
    
}

Measured memory_bytes: 3620
n, k = (int(x) for x in input().split())
c = {} 
t = 0
MOD = 1000000007
for x in range(k, 0, -1):
    q = k // x
    c[x] = pow(q, n, MOD) - sum(c[x * y] for y in range(2, q + 1))
    t += c[x] * x
    t = t % MOD
print(t)

Measured memory_bytes: 20656
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<long long> a(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    vector<long long> accum(n + 1);
    vector<long long> accum_xor(n + 1);
    for (int i = 1; i <= n; i++) {
        accum[i] = accum[i - 1] + a[i];
        accum_xor[i] = accum_xor[i - 1] ^ a[i];
    }


    long long cnt = 0;
    // start
    for (int i = 1; i <= n; i++) {
        // find end
        int lb = i, ub = n + 1;
        while (ub - lb > 1) {
            int half = (lb + ub) / 2;
            long long check1 = accum[half] - accum[i - 1];
            long long check2 = accum_xor[half] ^ accum_xor[i - 1];
            if (check1 == check2) {
                // ok
                lb = half;
            }
            else
                ub = half;
        }

        cnt += lb - i + 1;

    }
    cout << cnt << endl;
    return 0;
}

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

int n,m;
int beat[31];
int yuta[31];
int memo[31][1<<16];
int dp(int nowbeat,int bit);

main(){
  while(1){
    cin>>n>>m;
    if(n==0 && m==0) break;
    memset(beat,0,sizeof(beat));
    memset(yuta,0,sizeof(yuta));
    
    for(int i=0;i<n;i++){
      for(int j=0;j<16;j++){
	int a;
	cin>>a;
	beat[i] |= (a<<j);
      }
    }
    for(int i=0;i<m;i++){
      for(int j=0;j<16;j++){
	int b;
	cin>>b;
	yuta[i]|= (b<<j);
      }
    }
    memset(memo,0,sizeof(memo));
    cout<<dp(0,beat[0])<<endl;
  }
}
int dp(int nowbeat, int bit){
  if(nowbeat==n){
    return 0;
  }
  if(memo[nowbeat][bit]){
    return memo[nowbeat][bit];
  }

  int ans=0;
  for(int i=0;i<m;i++){
    ans=max(ans,dp(nowbeat+1,(bit & ~yuta[i]) | beat[nowbeat+1]) + __builtin_popcount(bit & yuta[i]));
  }
  return memo[nowbeat][bit]=ans;
}

Measured memory_bytes: 9108
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

ll rep_power_modM(ll a, ll n, ll M = MOD){
	if(n == 0)return 1;
	if(n%2 == 0){ll tmp = rep_power_modM(a,n/2,M); return tmp*tmp%M;}
	return a*rep_power_modM(a,n-1,M)%M;
}

int main(){
	int N;
	cin >> N;
	if(N == 1){
		cout << 0 << endl;
		return 0;
	}
	vector<ll> only0(N+1,0);
	vector<ll> only9(N+1,0);
	vector<ll> no(N+1,0);
	vector<ll> both(N+1,0);
	no[0] = 1;
	for(int i = 1; i <= N; ++i){
		rep(d,10){
			if(d == 0){
				only0[i] += no[i-1];
				only0[i] += only0[i-1];
				both[i] += only9[i-1];
			}else	if(d == 9){
				only9[i] += no[i-1];
				only9[i] += only9[i-1];
			 	both[i] += only0[i-1];	
			}else{
				only0[i] += only0[i-1];
				no[i] += no[i-1];
				only9[i] += only9[i-1];
			}
			both[i] += both[i-1];
			only9[i] %= MOD;
			only0[i] %= MOD;
			both[i] %= MOD;
			no[i] %= MOD;
		}
	}
	cout << both[N] << endl;	
	return 0;
}


Measured memory_bytes: 34412
//#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
#include<cstring>
#include<sstream>
#include <iomanip>

using namespace std;

typedef long long ll ;
typedef double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector< pair<int,int> > vii;
const double pi = 2*acos(0) ;

#define pf		  	printf
#define sf			  scanf
#define pb(a)         push_back(a)
#define mp			make_pair
#define fi			 first
#define se			 second
#define for0(i,n)        for(int i=0;i<n;i++)
#define for1(i,n)        for(int i=1;i<=n;i++)
#define forab(i,a,b)       for(int i=a;i<=b;i++)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define sq(a)		   (a)*(a)
#define nw				"\n"
#define abs(x)		fabs(x)
#define pcase(z,x)    cout<<"Case "<<z<<": "<<x<<"\n"
int main()
{
	string s;
	cin>>s;
	vi a;
	int i,j,sum=0,n=4;
	for0(i,s.size()) a.pb(s[i]-'0');
	for(i=0 ; i<(1<<n) ; i++){
		sum=0;
		vi d;
		for(j=0 ; j<n ; j++){
			if(i&(1<<j)) {sum+=a[j]; d.pb(a[j]);}
			else{sum-=a[j]; d.pb((-1)*a[j]);}
			}
		//cout<<sum<<nw;
		if(sum==7){
			d.pb(1);
			for(int x=0 ; x<4 ; x++){
				cout<<d[x];
				if(x!=3 && d[x+1]>=0) cout<<"+";
				}
			cout<<"="<<7<<nw;
			return 0;
			}
		}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using Graph = vector<vector<int>>;
using ll = long long;
using p = pair<int, int>;

int main()
{
    int k;
    int ans = 0;
    cin >> k;

    int amari = 7 % k;

    int i = 1;
    if (amari == 0)
    {
        cout << 1 << endl;
        return 0;
    }

    map<int, int> mp;
    do
    {
        i++;
        amari = (amari * 10 + 7) % k;
        if (amari == 0)
        {
            cout << i << endl;
            return 0;
        }
        else
        {
            if (mp[amari])
            {
                break;
            }
            mp[amari] = 1;
        }
    } while (true);

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

Measured memory_bytes: 50424
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace A
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var ni = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            Console.WriteLine(ni[0] - ni[1] + 1);
        }
    }
}


Measured memory_bytes: 11476
#include<stdio.h>
#include<stdlib.h>
#define LEN 100005
#define MAX 100000

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN + 1];
int head = 0,tail = 0,n;

void enqueue(P x){
  if(isFull()){
    printf("error_Full\n");
    exit(0);
  }
  Q[tail] = x;
  if((tail + 1) == MAX)tail = 0;
  else tail++;
}

P dequeue(){
  P x;
  if(isEmpty()){
    printf("error_Empty\n");
    exit(0);
  }
  x = Q[head];
  if((head + 1) == MAX)head = 0;
  else head++;
  return x;
}

int isEmpty(){
  return head == tail;
}

int isFull(){
  return head == (tail + 1)%MAX;
}

int min(int a, int b){
  return a < b ? a : b;
}

int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1;
  tail = n + 1;
  while(head != tail){
    u = dequeue();
    c = min(q,u.t);
    u.t -= c;
    elaps += c;
    if(u.t > 0)enqueue(u);
    else{
      printf("%s %d\n",u.name,elaps);
    }
  }
  return 0;
}



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

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

    string S[3];
    REP(i, 3) cin >> S[i];

    cout << S[0][0] << S[1][1] << S[2][2] << endl;

    return 0;
}

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

int main()
{
	int i, j, k, n, m, x, y, z, count=0;

	cin >> n >> m;

	vector <int> adj[n+1];
	bool used[n+1];
	queue <int> q;

	for(i=0; i<m; i+=1)
	{
		cin >> x >> y >> z;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}

	memset(used, 0, sizeof(used));

	for(i=1; i<=n; i+=1)
	{
		if(used[i]==1)
			continue;
		else
		{
			x=i;
			used[x]=1;
			q.push(x);
			count+=1;
		}

		while(!q.empty())
		{
			x=q.front();
			q.pop();

			k=adj[x].size();
			for(j=0; j<k; j+=1)
			{
				y=adj[x][j];
				if(used[y]==0)
				{
					used[y]=1;
					q.push(y);
				}
			}
		}
	}

	cout << count << endl;
}

Measured memory_bytes: 6648
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
	return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
	return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}
long long gcd(long long x,long long y){
	return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
	return x/gcd(x,y)*y;
}

// konoshita kara kaku

int main(void){
	int i,a=0,c;
	rep(i,3){
		c=getchar();
		if(c=='o')a++;
	}
	print(700+100*a);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main()
{
	int n;
	cin >> n;
	vector<int> h(n);
	rep(i, n) cin >> h[i];

	vector<int> cost(n); //DPのための表
	cost[0] = 0;
	cost[1] = abs(h[1]-h[0]);

	for(int i = 2; i < n; i++){
		cost[i] = min(cost[i-2] + abs(h[i-2]-h[i]), cost[i-1] + abs(h[i-1]-h[i]));
		//cout << cost[i] << " ";
	}

	cout << cost[n-1] << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int long long int
#define endl "\n"
using namespace std;
void solve()
{
    //Enter your code here Tanmay:)
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    int a[n];
    for(int i=0;i<n;i++)
    {
        a[arr[i]-1]=i;
    }
    for(int i=0;i<n;i++)
    {
        cout<<a[i]+1<<" ";
    }
}
signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 2432
#include<iostream>
using namespace std;
int main(){
	char s[100010];
	int len = 0;
	int cnt = 1;
	cin >> s;
	while(s[len])len ++;
	if(len % 2 == 0){
		if(s[len / 2] != s[len / 2 - 1])cnt = 0;
		else{
			for(int i = 1; i < len / 2; i ++){
				if(s[len / 2 + i] == s[len / 2 - 1 - i] && s[len / 2 + i] == s[len / 2])cnt ++;
				else break;
			}
		}
		
	}else{
		for(int i = 1; i <= len / 2; i ++){
			if(s[len / 2] == s[len / 2 + i] && s[len / 2] == s[len / 2 - i])cnt ++;
			else break;
		}
	}
	cout << cnt + len / 2;
	return 0;
}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <utility>

using namespace std;
struct vertex { double x, y; };

void kock(int d, vertex p1, vertex p2)
{
	if (d == 0)
		return;

	vertex s, t, u;
	s.x = (2 * p1.x + 1 * p2.x) / 3;
	s.y = (2 * p1.y + 1 * p2.y) / 3;
	t.x = (1 * p1.x + 2 * p2.x) / 3;
	t.y = (1 * p1.y + 2 * p2.y) / 3;
	u.x = (t.x - s.x) * cos(M_PI / 3) - (t.y - s.y) * sin(M_PI / 3) + s.x;
	u.y = (t.x - s.x) * sin(M_PI / 3) + (t.y - s.y) * cos(M_PI / 3) + s.y;

	kock(d - 1, p1, s);
	cout << s.x << " " << s.y << endl;
	kock(d - 1, s, u);
	cout << u.x << " " << u.y << endl;
	kock(d - 1, u, t);
	cout << t.x << " " << t.y << endl;
	kock(d - 1, t, p2);
}

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

	vertex p1, p2;
	p1.x = 0.0, p1.y = 0.0;
	p2.x = 100.0, p2.y = 0.0;

	cout << p1.x << " " << p1.y << endl;
	kock(n, p1, p2);
	cout << p2.x << " " << p2.y << endl;

	return 0;
}

Measured memory_bytes: 1256
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n;
	int b,f,r,v;
	int i,j,k,l;
	int house[5][4][11]={0};
	cin>>n;
	for(l=0;l<n;l++){
		cin>>b>>f>>r>>v;
		if(v>=0){
			house[b][f][r]+=v;
		}
		else{
			house[b][f][r]+=v;
		}
	}
	for(k=1;k<=4;k++){
		for(i=1;i<=3;i++){
			for(j=1;j<=10;j++){
				cout<<" "<<house[k][i][j];
			}
			cout<<endl;
		}
		if(k!=4){
			for(i=0;i<20;i++){
				cout<<"#";
			}
			cout<<endl;
		}
		
	}
	return 0;
}
		
			


Measured memory_bytes: 3124
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <bitset>
#include <iostream>
#include <deque>
#include <functional>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

using namespace std;

// #define int long long

#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

#define debug(x) cerr << #x << ": " << x << endl;

const int MOD = 1e9 + 7;

template <typename T>
T gcd(T m, T n) { return n == 0 ? m : gcd(n, m % n); }
template <typename T>
T lcm(T m, T n) { return n * m / gcd(n, m); }

signed main(void)
{
  int a, b;
  cin >> a >> b;
  cout << max(a - 2 * b, 0) << endl;
}


Measured memory_bytes: 256
N, M = gets.split.map(&:to_i)
MOD = 10**9 + 7

@fct, @inv, @finv = [1, 1], [1, 1], [1, 1]
(2 .. M + N).each do |i|
  @fct[i] = @fct[i - 1]*i % MOD
  @inv[i] = MOD - @inv[MOD % i]*(MOD/i) % MOD
  @finv[i] = @finv[i - 1] * @inv[i] % MOD
end
p = ->(n, k){@fct[n]*@finv[n - k]}
puts (0 .. N).inject(0){|s, k| (s + p[N, k]*@finv[k] * (k.even? ? 1 : -1) * p[M, k] * p[M - k, N - k]**2) % MOD}

Measured memory_bytes: 37864
//inlclude before define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<assert.h>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>
using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> P1;
typedef long long int ll;

//define
#define INF 1e9
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);i++)
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))


int main() {
	int n;
	cin >> n;
	int  a;
	VI cnt(9,0);
	rep(i, n) {
		cin >> a;
		if (0<=a &&a < 400)   cnt[0]++;
		else if(400<=a && a<800) cnt[1]++;
		else if (800 <= a && a<1200) cnt[2]++;
		else if (1200 <= a && a<1600) cnt[3]++;
		else if (1600 <= a && a<2000) cnt[4]++;
		else if (2000 <= a && a<2400) cnt[5]++;
		else if (2400 <= a && a<2800) cnt[6]++;
		else if (2800 <= a && a<3200) cnt[7]++;
		else cnt[8]++;
	}
	
	int so = 0;
	rep(i, 8) {
		if (cnt[i] > 0) so++;
	}

	int maxv = so + cnt[8];
	chmin(maxv,n);
	int minv;
	if (so==0) {
		minv = 1;
	} else {
		minv = so;
	}

	cout << minv << " " << maxv << endl;
}





Measured memory_bytes: 256
def input_from_console():
    n = int(input().strip())
    d_list = list(map(int, input().strip().split()))
    return n, d_list


def solve(n, d_list):
    result = 0
    divider = n //2
    d_list.sort()
    pre = d_list[:divider]
    lower = max(pre) + 1
    post = d_list[divider:]
    upper = min(post)
    if lower <= upper:
        result = upper - lower + 1
    return result


def main():
    n, d_list = input_from_console()
    print(solve(n, d_list))


if __name__ == "__main__":
    import sys

    if sys.gettrace():  # Check if the python interpreter is in debug mode or not.
        check_cases()
    else:
        main()


Measured memory_bytes: 14280
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String [] n = br.readLine().split(" ");
        
        Dice dice = new Dice(n[0], n[1], n[2], n[3], n[4], n[5]);
        
        int num = Integer.parseInt(br.readLine());
        
        for(int i = 0; i < num; i++) {
            String [] line = br.readLine().split(" ");
            System.out.println(dice.askRight(line[0], line[1]));
        }
    }
}

class Dice {
    private String top;
    private String front;
    private String right;
    private String left;
    private String back;
    private String bottom;
    
    public Dice(String top, String front, String right, String left, String back, String bottom) {
        this.top = top;
        this.front = front;
        this.right = right;
        this.left = left;
        this.back = back;
        this.bottom = bottom;
    }
    
    public String askRight(String top, String front) {
        setTop(top);
        setFront(front);
        return this.right;
    }
    
    private void setTop(String top) {
        for(int i = 0; i < 4; i++) {
            goNorth();
            if(this.top.equals(top)) {
                return;
            }
        }
        
        goEast();

        for(int i = 0; i < 4; i++) {
            goNorth();
            if(this.top.equals(top)) {
                return;
            }
        }
    }
    
    private void setFront(String front) {
        for(int i = 0; i < 4; i++) {
            leftRotation();
            if(this.front.equals(front)) {
                break;
            }
        }
    }
    
    private void leftRotation() {
        String tmp = this.front;
        this.front = this.right;
        this.right = this.back;
        this.back = this.left;
        this.left = tmp;
    }

    public String nowTopNum() {
        return this.top;
    }
    
    public void goSouth() {
        String tmp = this.front;
        this.front = this.top;
        this.top = this.back;
        this.back = this.bottom;
        this.bottom = tmp;
    }

    public void goNorth() {
        String tmp = this.front;
        this.front = this.bottom;
        this.bottom = this.back;
        this.back = this.top;
        this.top = tmp;
    }

    public void goEast() {
        String tmp = this.top;
        this.top = this.left;
        this.left = this.bottom;
        this.bottom = this.right;
        this.right = tmp;
    }

    public void goWest() {
        String tmp = this.top;
        this.top = this.right;
        this.right = this.bottom;
        this.bottom = this.left;
        this.left = tmp;
    }
}



Measured memory_bytes: 24352
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
using namespace std;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

template<typename ...Ts>
void show(Ts... ts){
  cout<<"#:";
  auto print=[](auto v){cout<<v<<" ";};
  initializer_list<int>{(void(print(ts)),0)...};
  cout<<endl;
}



int main(void){
    ll n,m,x,y,ans=0,cmp=0;
    cin>>n>>m;
    vector<ll> a(n,0);
    vector<ll> v(n,-1);
    vector<vector<ll>> g(n);
    rep(i,n)cin>>a[i];
    rep(i,m){
        cin>>x>>y;
        g[x].push_back(y);
        g[y].push_back(x);
    }

    priority_queue<ll,vector<ll>,greater<ll>> rest;
    
    rep(i,n){
        if(v[i]>0)continue;
        vector<ll> p;
        priority_queue<ll,vector<ll>,greater<ll>> cost;

        p.push_back(i);
        cost.push(a[i]);
        while(!p.empty()){
            ll c=p.back();
            p.pop_back();
            v[c]=a[c];
            for(ll nb:g[c]){
                if(v[nb]==-1){
                    p.push_back(nb);
                    v[nb]=a[nb];
                    cost.push(a[nb]);
                }
            }
        }
        ans+=cost.top();
        cmp+=1;
        cost.pop();
        while(!cost.empty()){
            rest.push(cost.top());
            cost.pop();
        }
    }
    
    if (cmp==1){
        cout<<0<<endl;
    }else if (rest.size()<cmp-2){
        cout<<"Impossible";
    }else{
        rep(i,2*(cmp-1)-cmp){
            ans+=rest.top();
            rest.pop();
        }
        cout<<ans;
    }
}


Measured memory_bytes: 10108
#include<iostream>
int main(){
    int a, b, c;
    std::cin >> a >> b >> c;
    if(a < b){
        if(b < c){
            std::cout << "Yes" << std::endl;
        }
        else{
            std::cout << "No" << std::endl;
        }
    }
    else{
        std::cout << "No" << std::endl;
    }
    return 0;
}

Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(a) int((a).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
const int mod = 1e9 + 7;
template<class T, class U> inline void add_self(T &a, U b){a += b;if (a >= mod) a -= mod;if (a < 0) a += mod;}
template<class T, class U> inline void min_self(T &x, U y) { if (y < x) x = y; }
template<class T, class U> inline void max_self(T &x, U y) { if (y > x) x = y; }

#define _deb(x) cout<<x;
void _print() {cerr << "]\n";} template <typename T, typename... V>void _print(T t, V... v) {_deb(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
template <class T, class U> void print_m(const map<T,U> &m, int w=3){if(m.empty()){cout<<"Empty"<<endl; return;}for(auto x: m)cout<<"("<<x.first<<": "<<x.second<<"),"<<endl;cout<<endl;}
template<class T, class U>void debp(const pair<T, U> &pr, bool end_line=1){cout<<"{"<<pr.first<<" "<<pr.second<<"}"; cout<<(end_line ? "\n" : ", ");}
template <class T> void print_vp(const T &vp, int sep_line=0){if(vp.empty()){cout<<"Empty"<<endl; return;}if(!sep_line) cout<<"{ ";for(auto x: vp) debp(x,sep_line);if(!sep_line) cout<<"}\n";cout<<endl;}
template <typename T>void print(const T &v, bool show_index = false){int w = 2;if(show_index){for(int i=0; i<sz(v); i++)cout<<setw(w)<<i<<" ";cout<<endl;}for(auto &el: v) cout<<setw(w)<<el<<" ";cout<<endl;}
template <typename T>void print_vv(const T &vv){if(sz(vv)==0) {cout<<"Empty"<<endl; return;} int w = 3;cout<<setw(w)<<" ";for(int j=0; j<sz(*vv.begin()); j++)cout<<setw(w)<<j<<" ";cout<<endl;int i = 0;for(auto &v: vv){cout<<i++<<" {";for(auto &el: v) cout<<setw(w)<<el<<" ";cout<<"},\n";}cout<<endl;}

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll n;
    while(cin>>n){
        string s;
        while(n>0){
            n-=1;
            s+=('a' + n%26);
            n/=26;
        }
        reverse(all(s));
        cout<<s<<"\n";
    }
    return 0;
}

Measured memory_bytes: 3640