akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"fmt"
)

const MOD = 1000000007

func ModAdd(a, b int64) int64 {
	return (a + b) % MOD
}

func ModMul(a, b int64) int64 {
	return a * b % MOD
}

func ModSub(a, b int64) int64 {
	r := (a%MOD - b%MOD) % MOD
	if r < 0 {
		r += MOD
	}
	return r
}

func ModDiv(a, b int64) int64 {
	return a % MOD * ModInv(b) % MOD
}

func ModPow(a, n int64) int64 {
	var r int64 = 1
	for n > 0 {
		if n&1 == 1 {
			r = r * a % MOD
		}
		a = a * a % MOD
		n >>= 1
	}
	return r
}

func ModInv(a int64) int64 {
	var b, u, v int64 = MOD, 1, 0
	for b > 0 {
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	u %= MOD
	if u < 0 {
		u += MOD
	}
	return u
}

func main() {
	var N, K int
	fmt.Scanf("%d %d\n", &N, &K)

	dp := [100010]int64{}
	for i := K; i > 0; i-- {
		dp[i] = ModPow(int64(K/i), int64(N))
		for j := 2; i*j <= K; j++ {
			dp[i] -= dp[j*i]
		}
	}
	sum := int64(0)
	for i := 1; i <= K; i++ {
		sum = ModAdd(sum, ModMul(int64(i), dp[i]))
	}
	fmt.Println(sum)

}


Measured memory_bytes: 2676
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using llong = long long;
using P = pair<int, int>;
const int inf = 1 << 20;
const int mod = 1e9 + 7;

int g[15][15];
int main() {
   int n;
   cin >> n;
   vector<int> a(n);
   rep(i, n) rep(j, n) g[i][j] = -1;
   rep(i, n) {
      int a;
      cin >> a;
      rep(j, a) {
         int x, y;
         cin >> x >> y;
         x--;
         g[i][x] = y;
      }
   }
   int ans = 0;
   rep(i, 1 << n) {
      vector<int> d(n);
      rep(j, n) {
         if (i >> j & 1) {
            d[j] = 1;
         }
      }
      bool isok = true;
      rep(j, n) {
         if (d[j]) {
            rep(k, n) {
               if (g[j][k] == -1)
                  continue;
               if (g[j][k] != d[k])
                  isok = false;
            }
         }
      }
      if (isok)
         ans = max(ans, __builtin_popcount(i));
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    vector<ll> h(N);
    REP(i, 0, N) {
        cin >> h[i];
    }
    const ll inf = 1LL << 60;
    auto dp = make_v(N, inf);
    dp[0] = 0;
    REP(i, 0, N) {
        REP(j, 1, K + 1) {
            if (i + j < N) {
                dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
            }
        }
    }

    cout << dp[N - 1] << endl;

    return 0;
}


Measured memory_bytes: 1792
/* Coached by Dukkha */
#include <stdio.h>
#include <stdlib.h>

#define N 300
#define M 300

int main() {
	static int ii[N * M + 1], jj[N * M + 1], xx[N * M + 1];
	int n, m, d, q, i, j, a;

	scanf("%d%d%d", &n, &m, &d);
	for (i = 0; i < n; i++)
		for (j = 0; j < m; j++) {
			scanf("%d", &a);
			ii[a] = i, jj[a] = j;
		}
	for (a = d + 1; a <= n * m; a++)
		xx[a] = abs(ii[a] - ii[a - d]) + abs(jj[a] - jj[a - d]);
	for (a = d + 1; a <= n * m; a++)
		xx[a] += xx[a - d];
	scanf("%d", &q);
	while (q--) {
		int l, r;

		scanf("%d%d", &l, &r);
		printf("%d\n", xx[r] - xx[l]);
	}
	return 0;
}


Measured memory_bytes: 2048
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.C
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var S = ReadText();
            try
            {
                for (int i = S.Length - 1; i >= 0; )
                {
                    var c = S[i];
                    if (c == 'm')
                    {
                        if (S[i - 1] == 'a' && S[i - 2] == 'e' && S[i - 3] == 'r' && S[i - 4] == 'd')
                        {
                            i -= 5;
                        }
                        else
                        {
                            return "NO";
                        }
                    }
                    else if (c == 'e')
                    {
                        if (S[i - 1] == 's' && S[i - 2] == 'a' && S[i - 3] == 'r' && S[i - 4] == 'e')
                        {
                            i -= 5;
                        }
                        else
                        {
                            return "NO";
                        }
                    }
                    else if (c == 'r')
                    {
                        if (S[i - 1] == 'e' && S[i - 2] == 'm' && S[i - 3] == 'a' && S[i - 4] == 'e' && S[i - 5] == 'r' && S[i - 6] == 'd')
                        {
                            i -= 7;
                        }
                        else if (S[i - 1] == 'e' && S[i - 2] == 's' && S[i - 3] == 'a' && S[i - 4] == 'r' && S[i - 5] == 'e')
                        {
                            i -= 6;
                        }
                        else
                        {
                            return "NO";
                        }
                    }
                }
            }
            catch (Exception)
            {
                return "NO";
            }

            return "YES";
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 26284
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define RFOR(i, begin, end) for(int i=(end)-1, i##_begin_=(begin);i>=i##_begin_;i--)
#define rep(i, N) FOR(i, 0, N)
#define rrep(i, N) RFOR(i, 0, N)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
using namespace std;
using ll = long long int;
using V = vector<ll>;
using P = pair<ll, ll>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
constexpr int mod = 1e9+7;
ll gcd(ll a, ll b) { return b? gcd(b, a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a, b)*b;}

ll a, b;

int main() {
    cin >> a >> b;
    ll ret = 1;
    if (b == 1) ret--;
    while(b>a) {
        b -= a-1;
        ret++;
    }
    cout << ret << endl;
    return 0;
}


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

using namespace std;

#define ll long long
#define pb push_back
#define endl "\n"
#define all(x) x.begin(), x.end()

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

	int n;
	cin >> n;
	ll x = n % 10;
	if(x == 2 || x == 4 || x == 5 || x == 7 || x == 9) {
		cout << "hon";
	} else if(x == 3) {
		cout << "bon";
	} else {
		cout << "pon";
	}
}


Measured memory_bytes: 3648
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

fn main() {
    input!{
      w: usize,
      h: usize,
      x: usize,
      y: usize,
    }
    if x*2 == w && y*2 == h {
        println!("{} {}", ((w*h) as f64 / 2.0) as f64,  1);
    } else {
        println!("{} {}", ((w*h) as f64 / 2.0) as f64,  0);
    }
}


Measured memory_bytes: 4352
N,A = map(int,input().split())
ls1 = [0] + list(map(int,input().split()))

dp = [[[0 for k in range(2600)] for j in range(51) ] for i in range(51)]
for i in range(51):
    dp[i][0][0] = 1
for j in range(1,N+1):
    for k in range(1,j+1):
        for s in range(2600):
            if s < ls1[j]:
                dp[j][k][s] = dp[j-1][k][s]
            elif s >= ls1[j]:
                dp[j][k][s] = dp[j-1][k-1][s-ls1[j]] + dp[j-1][k][s]
ans = 0
for k in range(1,N+1):
    ans += dp[N][k][k*A]
print(ans)

Measured memory_bytes: 122200
h,w=map(int,input().split())
t=[list(input())for i in range(h)]
def check(x,y):
    dx=[0,0,1,-1]
    dy=[1,-1,0,0]
    jugde=False
    for k in range(4):
        i=x+dx[k]
        j=y+dy[k]
        if 0<=i and i<h and 0<=j and j<w and t[i][j]=="#":
            jugde=True
    if jugde==False:
        return False
    return True
for i in range(h):
    for j in range(w):
        if t[i][j]=="#":
            if check(i,j):
                jugde=True
            else:
                print("No")
                exit()
print("Yes")


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define debugP int debug_point; cin>>debug_point;
const ll MOD= 1e9 + 7;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
template <class T>
vector<T> getv(ll n){
	vector<T> Vector_temp;
	rep(i,n){
		T input;
		cin >> input;
		Vector_temp.emplace_back(input);
	}
	return Vector_temp;
}
ll gcd(ll c,ll b){
    while(1){
        if(c%b!=0){
        ll tmp=b;
        b=c%b;
        c=tmp;
        }else{
            return b;
        }
    }
}
/* <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3*/


int main(){
    ll n,k;
    cin>>n>>k;
    ll sum=0;
    vector<pair<ll,ll>> a(n);
    rep(i,n){
        cin>>a[i].first>>a[i].second;
    }
    sort(a.begin(),a.end());
    rep(i,n){
        sum+=a[i].second;
        if(sum>=k){
            op(a[i].first);
            return 0;
        }
    }
    return 0;
}

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

using namespace std;


typedef long long int ll;
typedef vector<int>vi;
typedef deque<int> di;
#define f(i, a, b) for(int i = a; i < b; i++)

int main () {
ll n;
string s;
cin >> n;
cin >> s;
ll sum = 1;
f(i, 0, n) {
if (i != n-1 && s[i] != s[i+1]) {
    sum +=1;

}

}
cout << sum;
return 0;
}


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

int a[300001];
int main(int argc, const char * argv[]) {
    
    int n;
    
    scanf("%d",&n);
    
    for(int i=0;i<3*n;i++){
        scanf("%d",&a[i]);
    }
    
    sort(a,a+3*n);
    int end = 3*n-1;
    long long sum = 0;
    
    for(int i=0;i<n;i++){
        sum += a[end-1];
        end-=2;
    }
    
    
    printf("%lld\n",sum);
    
    return 0;
}

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

int main () {
  int K, A, B;
  cin >> K >> A >> B;
  
  int trial = K;
  int i = 1;
  while (1) {
    trial = K * i;
    if (A <= trial && trial <= B) {
      cout << "OK";
      return 0;
    } else if (B < trial) {
      break;
    }
    i++;
  }
  cout << "NG";
}

Measured memory_bytes: 3636
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y) 

n, X = map(int, input().split())
x = list(map(int, input().split()))
a = abs(x[0] - X)
for i in x[1:]:
  a = gcd(a, abs(i - X))
print(a)

Measured memory_bytes: 14252
export class Main {
  static main(input: string): string {
    const tmp: string[] = input.split("\n");
    const n: number = parseInt(tmp[0].split(" ")[0]);
    const p: number[] = tmp[1].split(" ").map(int => parseInt(int));
    const q: number[] = tmp[2].split(" ").map(int => parseInt(int));
    const allList: number[] = [];
    for (let i = 1; i <= n; i++) {
      allList.push(i);
    }
    const pList: number[][] = Main.add(allList);
    let a = 0;
    let b = 0;
    for (let i = 0, len = pList.length; i < len; i++) {
      const l = pList[i];
      let pBoo = true;
      let qBoo = true;
      for (let j = 0; j < n; j++) {
        pBoo &= p[j] == l[j];
        qBoo &= q[j] == l[j];
      }
      if (pBoo) {
        a = i;
      }
      if (qBoo) {
        b = i;
      }
    }
    return `${Math.abs(a - b)}`;
  }

  static add(remainList: number[]): number[][] {
    let list = [];
    for (let i = 0, len = remainList.length; i < len; i++) {
      const a = remainList[i];
      const r = remainList.slice(0, i).concat(remainList.slice(i + 1, remainList.length));
      if (r.length == 0) {
        list.push([a]);
        continue;
      }
      const ll = Main.add(r);
      for (let j = 0, lenj = ll.length; j < lenj; j++) {
        ll[j].unshift(a);
      }
      list = list.concat(ll);
    }
    return list;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));


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

using namespace std;

int n, s;

int solve(int cnt, int num, int sum) {

    if(cnt == n) {
        if(sum == s) return 1;
        else return 0;
    }

    int ret = 0;
    for(int i = num + 1; i <= 9; ++i) {
        ret += solve(cnt + 1, i, sum + i);
    }
    return ret;

}

int main() {

    while(cin >> n >> s, n || s) {
        cout << solve(0, -1, 0) << endl;
    }

}

Measured memory_bytes: 1160
import java.io.*;
import java.util.*;

public class Main{
    public static void main(String[] args) throws Exception {
        BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        int n = Integer.parseInt(buffer.readLine());
        long num = 0;
        int t = 0, ans = -1;
        while (t++<=n){
            num = (num*10)+7;
            num %= n;
            if (num%n==0){
                ans = t;
                break;
            }
        }
        sb.append(ans);
        System.out.println(sb);
    }
}


Measured memory_bytes: 32632
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MAX 510000
#define rrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define dcout cout<<fixed<<setprecision(15);
#define mp make_pair
#define pb push_back

using namespace std;
typedef long long int  ll;
typedef pair<ll, ll> P;

constexpr int MOD = 1e9 + 7;
constexpr ll inf = 1LL << 60;

template< typename S, typename T >
inline void chmax(S &a, const T &b) { if(a < b) a = b; }
 
template< typename S, typename T >
inline void chmin(S &a, const T &b) { if(a > b) a = b; }
 

//lcm//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//a^n mod p//
ll modpow(ll a, ll n, ll p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p;
  ll t = modpow(a, n / 2, p);
  return (t * t) % p;
}

//inversemod//
ll modinv(ll a, ll m) {
	if(m==0)return (ll)1;
	ll b = m, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];
// 
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//LARGE n
ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}
	return k;
}

//radP
ll rad(ll u, ll p){
ll cnt=0;
	while(u%p==0){
		u/=p;
		cnt++;
	}
	return cnt;
}


////////////////////////////////////////////////////////////////////

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

int cnt=0;

int n=s.size();
for(int i=0;i<n;i++){
	if(s[i]=='?')s[i]='D';
}

cout<<s<<endl;


}




Measured memory_bytes: 3752
using System;
namespace ConsoleTest {
  class Program {
    static void Main(string[] args) {
      int a = int.Parse(Console.ReadLine());
      if (a == 1) {
        Console.WriteLine(2);
      } else {
        if (a % 2 == 0) {
          Console.WriteLine(a);
        } else {
          Console.WriteLine(a * 2);
        }
      }
    }
  }
}

Measured memory_bytes: 11092
import sys
input = sys.stdin.readline

n, k = map(int, input().split())
h = list(map(int, input().split()))
dp = [float('inf')] * (n + k + 10)
dp[0] = 0

for i in range(n):
    for j in range(1, k + 1):
        if i + j < n:
            if dp[i + j] == float('inf'):
                dp[i + j] = dp[i] + abs(h[i + j] - h[i])
            else:
                dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]))
        else:
            break


print(dp[n-1])


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

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

fn main() {
	let a: u32 = read();
    let b: u32 = read();
    if a*b%2 == 0 {
    	println!("Even");
    } else {
    	println!("Odd");
    }
}

Measured memory_bytes: 4352
#[macro_export]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[doc(hidden)]
#[macro_export]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[doc(hidden)]
#[macro_export]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: i64,
    }

    let mut ans = vec![];
    let mut n = n;
    let mut cur = 1;
    let mut k = 0;

    while n != 0 {
        if n & (1 << k) != 0 {
            ans.push('1');
            n -= cur;
        } else {
            ans.push('0')
        }
        cur *= -2;
        k += 1;
    }
    ans.reverse();
    if ans.len() == 0 {
        ans.push('0');
    }

    use std::iter::FromIterator;
    println!("{}", String::from_iter(ans.into_iter()));
}


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

const ll MAXN = 200000;
const ll INF = 1001001001;

ll N, K, tmp=0;
vector<ll> ans;
vector<pair<ll,ll>> G;

struct UnionFind {
    vector<int> size, parents;
    UnionFind() {}
    UnionFind(int n) {  // make n trees.
        size.resize(n, 0);
        parents.resize(n, 0);
        for (int i = 0; i < n; i++) {
            makeTree(i);
        }
    }
    void makeTree(int x) {
        parents[x] = x;  // the parent of x is x
        size[x] = 1;
    }
    bool isSame(int x, int y) { return findRoot(x) == findRoot(y); }
    bool unite(int x, int y) {
        x = findRoot(x);
        y = findRoot(y);
        if (x == y) return false;
        if (size[x] > size[y]) {
            parents[y] = x;
            size[x] += size[y];
        } else {
            parents[x] = y;
            size[y] += size[x];
        }
        return true;
    }
    int findRoot(int x) {
        if (x != parents[x]) {
            parents[x] = findRoot(parents[x]);
        }
        return parents[x];
    }
    int treeSize(int x) { return size[findRoot(x)]; }
};

signed main(){
    cin >> N >> K;
    UnionFind tree(N);
    for(int i=0;i<K;i++) {
        ll a, b;
        cin >> a >> b;
        G.push_back(make_pair(a,b));
    }
    ans.push_back(N*(N-1)/2);
    while(!G.empty()) {
        pair<ll,ll> p = G.back();
        G.pop_back();
        if(!tree.isSame(p.first-1, p.second-1)) ans.push_back(ans.back()-tree.treeSize(p.first-1)*tree.treeSize(p.second-1));
        else ans.push_back(ans.back());
        tree.unite(p.first-1, p.second-1);
    }
    ans.pop_back();
    for(int i=0;i<K;i++) {        
        cout << ans.back() << endl;
        ans.pop_back();
    }
    return 0;
}

Measured memory_bytes: 6256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <deque>
#include <array>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "]"; return os; }

const LL MOD = 1000000007;

struct WEdge{
    LL u, v, w;
    WEdge(){}
    WEdge(const WEdge& op):u(op.u),v(op.v),w(op.w){}
    WEdge(LL u_, LL v_, LL w_):u(u_),v(v_),w(w_){}
    bool operator<(const WEdge& op) const{ return this->w < op.w; }
    bool operator>(const WEdge& op) const{ return this->w > op.w; }
};


LL Kruskal(vector<vector<pair<LL,LL>>>& edge, WEdge start){
    LL n = edge.size();
    priority_queue<pair<LL,LL>, vector<pair<LL,LL>>,  greater<pair<LL,LL>>> q;
    vector<LL> memo(n);
    LL total = start.w;
    memo[start.u] = 1;
    memo[start.v] = 1;
    for(pair<LL,LL> p: edge[start.u]){
        if(p.first == start.v) continue;
        q.push(pair<LL,LL>(p.second, p.first));
    }
    for(pair<LL,LL> p: edge[start.v]){
        if(p.first == start.u) continue;
        q.push(pair<LL,LL>(p.second, p.first));
    }
    while(!q.empty()){
        LL w = q.top().first;
        LL cur = q.top().second;
        q.pop();
        if(!memo[cur]){
            memo[cur] = 1;
            total += w;
            for(pair<LL,LL> p: edge[cur]){
                if(!memo[p.first]) q.push(pair<LL,LL>(p.second, p.first));
            }
        }
    }
    return total;
}


LL countUniColor(vector<LL>& mst_w, LL x){
    LL cnt1 = lower_bound(mst_w.begin(), mst_w.end(), x+1) - mst_w.begin();
    LL cnt2 = mst_w.size() - cnt1;
    LL ans = 1;
    for(LL i = 0; i < cnt2 + (cnt1>0)?1:0; ++i){
        ans = ans * 2 % MOD;
    }
    return ans;
}


int main(){
    LL n, m, x;
    cin >> n >> m >> x;
    vector<WEdge> edge_list;
    vector<vector<pair<LL,LL>>> edge(n);
    for(LL i = 0; i < m; ++i){
        LL u, v, w;
        cin >> u >> v >> w;
        u--; v--;
        edge_list.emplace_back(u, v, w);
        edge[u].emplace_back(v, w);
        edge[v].emplace_back(u, w);
    }

    if(n == 1){
        cout << 0 << endl;
        return 0;
    }

    vector<LL> mst_w(m);
    for(LL i = 0; i < m; ++i){
        mst_w[i] = Kruskal(edge, edge_list[i]);
    }
    sort(mst_w.begin(), mst_w.end());
    cout << (MOD + countUniColor(mst_w, x-1) - countUniColor(mst_w, x)) % MOD << endl;

    return 0;
}



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

int main(){
  long long N;
  cin >> N;
  vector<long long> sum(N+1);
  sum.at(0)=0;
  for(long long i=1; i<=N; i++){
    long long A;
    cin >> A;
    sum.at(i)=sum.at(i-1)+A;
  }
  long long div=sum.at(N)+1;
  for(long long i=0; i<=N; i++){
    div=min(div, abs(sum.at(N)-sum.at(i)*2));
  }
  cout << div << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

template<class T>
struct Vec2
{
	Vec2(){}
	Vec2(T _x, T _y) : x(_x), y(_y) {}

	Vec2 operator+(const Vec2& rhs) const { return Vec2(x + rhs.x, y + rhs.y); }
	Vec2 operator-(const Vec2& rhs) const { return Vec2(x - rhs.x, y - rhs.y); }
	Vec2 operator*(T s) const { return Vec2(x*s, y*s); }
	Vec2 operator/(T s) const { return Vec2(x/s, y/s); }
	T dot(const Vec2& rhs) const { return x*rhs.x + y*rhs.y; }
	T cross(const Vec2& rhs) const { return x*rhs.y - y*rhs.x; }
	T sqlength() const { return x*x + y*y; }
	double length() const { return sqrt(sqlength()); }
	bool operator<(const Vec2& rhs) const
	{
		if (x != rhs.x) return x < rhs.x;
		return y < rhs.y;
	}

	T x;
	T y;
};

template<class T>
T cross(const Vec2<T> &O, const Vec2<T> &A, const Vec2<T> &B)
{
	return (A - O).cross(B - O);
}

template<class T>
double area(const vector<Vec2<T> >& poly)
{
	double ans = 0.0;
	for (size_t i = 0; i < poly.size() - 1; i++) {
		ans += poly[i].cross(poly[i+1]);
	}
	return 0.5*ans;
}

int main()
{
	typedef Vec2<long long> Vec;

	int n;
	cin >> n;
	vector<Vec> poly(n);
	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		poly[i] = Vec(x, y);
	}
	poly.push_back(poly[0]);
	printf("%.1f\n", area(poly));
	return 0;
}


Measured memory_bytes: 3232
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define YY cout << "Yes" << endl;
#define NN cout << "No" << endl;
#define ve vector
const int INF = 1000000007;
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
// *max_element(all(d));
class UnionFind{
  private:
    vector<int>par;
  public:
    UnionFind(int n):par(n,-1){}
    int root(int x){
      if(par[x] < 0)return x;
      return par[x] = root(par[x]);
    }
    bool unite(int x,int y){
      x = root(x); y = root(y);
      if (x == y) return false;
      if (par[x] > par[y]) swap(x, y);
      par[x] += par[y];
      par[y] = x;
      return true;
    }
    bool same(int x,int y){
      return root(x) == root(y);
    }
    int size(int x) {
      return -par[root(x)];
    }
};
int solve(){ 
  int n,m;
  cin >> n >> m;
  vector<pair<int,int>>v(m);
  vector<ll>anser;
  ll ans = n * (ll)(n - 1) / 2;
  UnionFind uf(n);
  rep(i,m){
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    v[i].first = a;
    v[i].second = b;
  }
  
  for(int i = m - 1; i >= 0; i--){
    int a = v[i].first,b = v[i].second;
    anser.push_back(ans);
    if(uf.same(a,b))continue;
    ans-=uf.size(a)*(ll)uf.size(b);
    uf.unite(a,b);
  }
  reverse(all(anser));
  rep(i,m)cout << anser[i] << endl;
  return 0; 
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16) << endl; 
  solve();
  return 0;
} 

Measured memory_bytes: 3444
#include <iostream>
#define NUM 10000
#define INF 1<<20

using namespace std;

int main(){
    long long a[NUM], max=-INF, min=INF, sum=0, i;
    cin >> i;
    i=0;
    while (cin >> a[i]) {
        if (max < a[i]) max = a[i];
        if (min > a[i]) min = a[i];
        sum += a[i++];
    }
    cout << min << ' ' << max << ' ' << sum << endl;
    return 0;
}


Measured memory_bytes: 3176
#include <cstdio>
#include <algorithm>
#include <iostream>

using namespace std;
int main() {
    int N=0;
    int bit;
    int a[500];
    int i=0;
    scanf("%d", &N);

    if(N==0||N==1){
        printf("%d", N);
        return 0;
    }
    while(N!=0){
        a[i] = abs(N%(-2));
        if(N%(-2)==-1){
            N = N/(-2)+1;
        }else{
            N = N/(-2);
        }
        i++;
    }

    for(i=i-1; i>=0; i--){
        printf("%d", a[i]);
    }
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define f(i, x, n) for(int i = x; i < n; i++)
#define dbg(x) cout << x << endl
#define dbg2(x, y) cout << x << "  " << y << endl
#define dbg3(x, y, z) cout << x << "  " << y << "  " << z << endl
#define mod 1000000007
using namespace std;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int ans = 0;
    if(k > a){
        ans += a;
        k -= a;
        if(k > b){
            k -= b;
            ans -= k;
        }
    }else{
        ans = k;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3652
from sys import stdin
from itertools import groupby

n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))

li.sort(reverse=True)
lin = []
for key, value in groupby(li):
    lin.append((key,len(list(value))))

mae = 0
ato = 0
for i in lin:
    if i[1] >= 4 and mae == 0:
        mae = i[0]
        ato = i[0]
    elif i[1] >= 2 and mae == 0:
        mae = i[0]
    elif i[1] >= 2 and ato == 0:
        ato = i[0]

print(mae*ato)

Measured memory_bytes: 15028
R,G,B=map(int,input().split())
K = int(input())
    
while (B<=G or G<=R) and K>0:
    if R>=G:
        G = G*2
        K = K-1
    if G>=B:
        B = B*2
        K = K-1
if R<G and G<B and K>=0:
    print("Yes")
else:
    print('No')

Measured memory_bytes: 8880
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>
#include <cstdint>



#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rrep(i, n) for(ll i = (ll)(n-1); i >= 0; i--)
#define repi(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rrepi(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);i--)

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

template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;


template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;

  modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  u64 &value() noexcept { return a; }
  u64 &value() const noexcept { return a; }
  modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
  modint pow(u64 exp){
    modint res=1,rhs=*this;
    while (exp) {
      if (exp % 2) {
        res *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return res;
  }

  friend ostream& operator<<(ostream& os,modint& rhs){
    os << rhs.value();
    return os;
  }

  friend istream& operator>>(istream &is,modint &rhs){
      is>>rhs.value();
      rhs.value()%=Modulus;
      return is;
  }

};
using mint=modint<(ll)1e9+7>;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,k;cin>>n>>k;
  vector<mint>dp(k+1);
  dp[0]=1;
  rep(i,n){
    ll a;cin>>a;a++;
    rrep(j,k+1-a)dp[j+a]-=dp[j];
  }
  rep(i,n)rep(j,k)dp[j+1]+=dp[j];
  cout<<dp[k]<<endl;

  return 0;

}


Measured memory_bytes: 1024
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        String s=sc.nextLine();
        char[] array=s.toCharArray();
        if(array[0]==array[1] && array[1]==array[2] && array[2]==array[3])
            System.out.println("No");
        else if(array[0]==array[1] && array[2]==array[3])
            System.out.println("Yes");
        else if(array[0]==array[2] && array[1]==array[3])
            System.out.println("Yes");
        else if(array[0]==array[3] && array[1]==array[2])
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}

Measured memory_bytes: 35356
n,a,b = map(int,input().split())
s=list(input())
ca = 0
cb = 0
for i in range(n):
    if s[i] == 'a' and ca + cb < a + b:
        print('Yes')
        ca += 1
    elif s[i] == 'b' and ca + cb < a + b and cb < b:
        print('Yes')
        cb += 1
    else:
        print('No')

Measured memory_bytes: 4712
#include <bits/stdc++.h>
using namespace std;
 
int main(int argc, char const *argv[]) {
  string s;
  int ans = 0, cnt = 0;
  cin >> s;
 
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C') {
      cnt++;
      ans = max(ans, cnt);
    } else {
      cnt = 0;
    }
  }
 
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#[allow(dead_code)]
fn main() {
    let n = i::u();
    let xy = i::iv2(n);
    let mut map = HashMap::new();
    for a in 0..n {
        for b in 0..n {
            if a == b {
                continue;
            }
            // aからbへの遷移のhashを数える
            let k = format!("{}, {}", xy[a].0 - xy[b].0, xy[a].1 - xy[b].1);
            if !map.contains_key(&k) {
                map.insert(k.clone(), 1);
            } else {
                *map.get_mut(&k).unwrap() += 1;
            }
        }
    }
    let mut ma = 0;
    for m in map {
        ma = max(ma, m.1)
    }
    println!("{}", n - ma);
}

#[allow(unused_imports)]
use std::cmp::*;
use std::collections::HashMap;
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}


Measured memory_bytes: 4352
S = input()
a_dict = dict()
count = 0
for word in S:
  a_dict.setdefault(word, count)
  if word in a_dict.keys():
    a_dict[word] += 1
if len(a_dict) != 2:
  print("No")
else:
  for value in a_dict.values():
    if value != 2:
      print("No")
      break
    else:
      print("Yes")
      break
  

Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
const int N = 2e5 + 100;
int n, d[N];

int main() {
	
	cin >> n;
	
	for(int i = 1; i <= n; i++) {
		int x; scanf("%d", &x);
		d[x]++;
	}
	
	int ans = 0;
	for(int i = 1; i <= 1e5; i++) {
		d[i] += d[i-1];
		if(d[i] == n/2) ans++;
		if(d[i] > n / 2) break;
	}
	cout << ans << endl;
	return 0;	
} 

Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[][] l = new char[8][8];
        for (int i = 0; i < 8; i++) {
            l[i] = sc.next().toCharArray();
        }
        char[][] t = new char[8][8];
        for (int i = 1; i < 4; i++) {
            System.out.println(i * 90);
            for (int j = 0; j < 8; j++) {
                for (int k = 0; k < 8; k++) {
                    t[j][k] = l[7 - k][j];
                    System.out.print(t[j][k]);
                }
                System.out.println();
            }
            for (int j = 0; j < 8; j++) {
                l[j] = t[j].clone();
            }
        }
    }
}



Measured memory_bytes: 26152
n=int(input())
def prime(INF=10**6+1):
  p=[1]*INF
  for i in range(2,INF):
    if p[i]:
      for j in range(2*i,INF,i):p[j]=0
  p[0],p[1]=0,0
  return p
p=prime()
a=[]
cnt=0
for i in range(10**6+1):
  if p[i] and i%5==1:
    a+=[i]
    cnt+=1
  if cnt==n:break
print(*a)

Measured memory_bytes: 81412
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define repr(i,n) for(int i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;

int main() {
    int n;
    cin >> n ;
    vector<int> vec(n);
    vector<int> vec_ans(n);

    rep(i,n-1){
        cin >> vec.at(i);
      	//vec_ans.at(i) = -1;
    }
  
  
  
  	int through = 0;
  	for(int i = 0; i < n-1; i ++){
      if(i==0){
        vec_ans.at(0) = vec.at(0);
      }
      if(i == n-2){
        if(through == 1){
          vec_ans.at(n-2) = vec.at(n-2);
        }
        vec_ans.at(n-1) = vec.at(n-2);
        continue;
      }
      
      if(through == 1){
        through = 0;
        vec_ans.at(i) = vec.at(i);
      }
      
      if(vec.at(i) <= vec.at(i+1)){
        vec_ans.at(i+1) = vec.at(i);
      }
      if(vec.at(i) > vec.at(i+1)){
        through = 1;
      }
      
    }
  
  	ll ans = 0;
  	rep(i,n){
      //cout << "i = " << vec_ans.at(i) << endl;
      ans += vec_ans.at(i);
    }
  
  	cout << ans << endl;


}



Measured memory_bytes: 256
#64C

n = int(input())
a = list(map(int,input().split()))
color = [0] * 8
wc = 0

for i in range(n):
    for j in range(8):
        if a[i] >= j*400 and a[i] <= (j+1)*400 - 1:
            color[j] = 1
    if a[i] >= 3200:
        wc += 1
            
mi = sum(color)
ma = mi + wc

print(max(mi,1) , ma)

Measured memory_bytes: 38256
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <bitset>
#include <set>
#include <iomanip>
#include <functional>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'a' = 97

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

    string ans;
    if (d == 25) ans = "Christmas";
    else if (d == 24) ans = "Christmas Eve";
    else if (d == 23) ans = "Christmas Eve Eve";
    else ans = "Christmas Eve Eve Eve";

    cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.AbstractMap;
import java.util.HashSet;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		solve(sc,out);

		out.flush();
	}

	public static void solve(FastScanner sc, PrintWriter out) {
		HashSet<Integer> set = new HashSet<Integer>();
		for(int i = 0; i < 3; i++) set.add(sc.nextInt());
		out.println(set.size());
	}

	public static int gcd(int a, int b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}

	public static long gcd(long a, long b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(final K key, final V value) {
        super(key, value);
    }
 }

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
     }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

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


int main(){
    long long x;
    cin >> x;
    int i;
    long long y = 100;
    for(i=1; ; i++){
        y += y/100;
        if(x <= y) break;
    }
    cout << i;
    cout << endl;
    return 0;
}


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

const long double EPS = 1e-10;
const long long INF = 1e18;
const int MOD = (int)1e9 + 7;
const long double PI = acos(-1.0L);

int main()
{
  double a, b;
  cin >> a >> b;
  rep(n, 10000)
  {
    int za = n * 8 / 100;
    int zb = n * 10 / 100;
    if (a == za && b == zb)
    {
      cout << n << endl;
      return 0;
    }
  }
  cout << -1 << endl;

  return 0;
}

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

int main() {
    ios_base::sync_with_stdio(false);	
    cin.tie(0);
	int a, ans;
	for (int i = 0; i < 5; i++) {
		cin >> a;
		if (a == 0) {
			ans = i + 1;
		}
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>

int main()
{
   int N;
   scanf("%d", &N);

   int count = 0;

   for (int i=1; i <= N; i++) {
      if (i < 10)
         count++;
      else if (100<=i && i<= 999)
         count++;
      else if (10000<=i && i<=99999)
         count++;

   }

   printf("%d\n", count);
   return 0;
}


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

int dp[25000];

void upd(int &x,int y){
	if(x>y)x=y;
}

int a[2000],b[2000];
signed main()
{
	memset(dp,0x3f,sizeof dp);
	dp[0]=0;
	int n,h;cin>>h>>n;
	int ans=2e9;
	for(int i=1;i<=n;i++)cin>>a[i]>>b[i];
	for(int i=1;i<=n;i++){
		//	cout<<i<<endl;
		for(int j=0;j<=2e4;j++){
			if(j-a[i]>=0)upd(dp[j],dp[j-a[i]]+b[i]);
			if(j>=h)upd(ans,dp[j]);
		//	cout<<j<<" "<<dp[j]<<endl;
		}
	}
	cout<<ans<<endl;
	

	getchar();getchar();
	
}

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

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

int main() {
    int h, a;
    cin >> h >> a;

    cout << ((h % a == 0) ? (h/a) : (h / a + 1)) << endl;

return 0;
}

Measured memory_bytes: 256