akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
// #include <boost/multiprecision/cpp_int.hpp> 

#define gc getchar//_unlocked
#define pc putchar//_unlocked
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define pp pair<int,int>
#define ppl pair<ll,ll>
#define bigint boost::multiprecision::cpp_int
#define finp ios_base::sync_with_stdio(0);cin.tie(0);
#define bc __builtin_popcountll
#define afor(i,a,b) for(int i=a;i<=b;++i)
#define bfor(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vpp vector<pp>
#define vll vector<ll>

using namespace std;
using namespace __gnu_pbds;

char putnb[20];
void putn(ll n) {if(!n)pc('0');if(n<0)pc('-'),n=0-n;int pi=0;while(n)putnb[pi++]=(n%10)+'0',n/=10;while(pi)pc(putnb[--pi]);}
void sci(int *x) {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x = (int)((((*x)<<1) + ((*x)<<3)) + c - 48);}
void scll(ll *x)  {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x =  (ll)((((*x)<<1) + ((*x)<<3)) + c - 48);}
ll fp(ll a,ll b,ll c) {if(b==0)return 1%c; if(b==1)return a%c; ll ret=fp(a,b/2,c); ret=(ret*ret)%c; if(b&1)ret=(ret*a)%c; return ret;}

const ll mod=1e9 +7;
const ll mod2=1999999973;
const ll inf=1e18;
const int infs=1e9 + 1000;
const int N=100000;
const long double PI = acos(-1);

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

ll A[N+5];
int main()
{
  finp;
  ll n,k;
  cin>>n>>k;
  afor(i,1,n)cin>>A[i];
  sort(A+1,A+n+1);
  if(n == 1)
  {
    if(k == A[1])cout<<"POSSIBLE";
    else cout<<"IMPOSSIBLE";
    return 0;
  }
  ll gc = 0;
  afor(i,1,n)
  {
    gc = __gcd(gc,A[i]);
  }

  if(k<=A[n] && k%gc==0)cout<<"POSSIBLE";
  else cout<<"IMPOSSIBLE";
return 0;
}

Measured memory_bytes: 1024
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split().Select(z => int.Parse(z)).ToArray();
            int a = line[0], b = line[1], C = line[2];

            var c = Math.Sqrt(a * a + b * b - (2 * b * a * Math.Cos(C * (Math.PI / 180))));

            var L = a + b + c;
            var s = (a + b + c) / 2;
            var S = Math.Sqrt(s * (s - a) * (s - b) * (s - c));
            var h = 2 * S / a;

            Console.WriteLine($"{S} {L} {h}");
        }
    }
}


Measured memory_bytes: 18404
#include <vector>
#include <iostream>
#include <cstdio>

using namespace std;
typedef long long ll;

int nxt() {
    int x;
    scanf("%d", &x);
    return x;
}

template <class T>
T remin(T &x, T val) {
    if (x > val) {x = val;}
    return x;
}

template <class T>
T remax(T &x, T val) {
    if (x < val) {x = val;}
    return x;
}
using pii = pair<int, int>;

void solve() {
    int n = nxt();
    int k = nxt();
    vector<pii> p(n);
    vector<int> c(n);
    for (int i = 0; i < n; ++i) {
        p[i].first = nxt();
        p[i].second = nxt();
        char cc[4];
        scanf("%s", cc);
        if (cc[0] == 'B') {
            c[i] = 1;
        } else {
            c[i] = 0;
        }
    }
    vector<pii> o(n);
    vector<int> ct(n);
    for (int i = 0; i < n; ++i) {
        o[i].first = p[i].first % k;
        o[i].second = p[i].second % k;
        ct[i] = (p[i].first / k + p[i].second / k) & 1;
    }

    int ans = 0;

    for (int dx = 0; dx <= k; ++dx) {
        vector<int> so[2];
        for (int i = 0; i < 2; ++i) {
            so[i].assign(k + 1, 0);
        }
        for (int i = 0; i < n; ++i) {
            int cc = ct[i];
            if (dx + o[i].first >= k) cc ^= 1;
            so[cc == c[i]][o[i].second] += 1;
        }
        for (int t = 0; t < 2; ++t) {
            for (int i = 0; i < k; ++i) {
                so[t][i + 1] += so[t][i];
            }
        }
        int curans = so[1][k];
        ans = max(ans, curans);
        for (int dy = 0; dy <= k; ++dy) {
            int add0 = so[0][k] - so[0][k - dy];
            int add1 = so[1][k] - so[1][k - dy];
            ans = max(ans, curans + add0 - add1);
        }
        curans = so[0][k];
        ans = max(ans, curans);
        for (int dy = 0; dy <= k; ++dy) {
            int add0 = so[1][k] - so[1][k - dy];
            int add1 = so[0][k] - so[0][k - dy];
            ans = max(ans, curans + add0 - add1);
        }
    }
    cout << ans << "\n";
}

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "r", stdout);
#endif

//    int t = nxt();
//    for (int i = 0; i < t; ++i) {
//        solve();
//    }
    solve();
    return 0;
}


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

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
template <typename T>
constexpr T INF = numeric_limits<T>::has_infinity ? numeric_limits<T>::infinity() : numeric_limits<T>::max() / 2;

#define REP(i, stop) FOR(i, 0, stop)
#define FOR(i, start, stop) for (int i = start, i##_len = stop; i < i##_len; ++i)
#define RREP(i, n) for (int i = n; i-- > 0;)
#define ALL(v) (v).begin(), (v).end()

template<typename T>
istream& operator>>(istream& in, vector<T>& a) { for (T& x : a) cin >> x; }

void LOG(const int& x) { cerr << x << "\n"; }
void LOG(const vector<int>& a) { for (int x : a) cerr << x << " "; cerr << "\n"; }

int ceil(int a, int b) { return (a - 1) / b + 1; }

class UnionFind {
private:
  vector<int> par;
  vector<int> rnk;
  int find(int x) { return par[x] == x ? x : par[x] = find(par[x]); }
public:
  UnionFind(int size) { par.resize(size); rnk.resize(size); REP(i, size) par[i] = i, rnk[i] = 0; }
  void unite(int x, int y) { x = find(x); y = find(y); if (x == y) return; if (rnk[x] < rnk[y]) { par[x] = y; } else { par[y] = x; if (rnk[x] == rnk[y]) rnk[x]++; } }
  bool same(int x, int y) { return find(x) == find(y); }
};

struct InitCpp { InitCpp() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
} } initCpp;

signed main() {
  int n;
  cin >> n;
  vector<int> m(100010);
  REP(i, n) {
    int a;
    cin >> a;
    m[a] += 1;
    m[a + 1] += 1;
    m[a + 2] += 1;
  }
  cout << (*max_element(ALL(m))) << endl;
}

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

int T[100010];
int find(int m,int x){
	int r=0,l=m-1,ans=0;
	while(1){	
		if(r>l)break;
		ans++;
		if(T[(r+l)/2]==x)return ans;
		if(T[(r+l)/2]>x)l=(r+l)/2-1;
		else if(T[(r+l)/2]<x)r=(r+l)/2+1;
	}
	return ans;
}
int main(){
	int n,k,num,ans;
	while(1){
		cin>>n;
		if(n==0)break;
		for(int i=0;i<n;i++){
			cin>>T[i];
		}
		cin>>k;
		ans=find(n,k);
		cout<<ans<<endl;
	}
	return 0;
}

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

int main() {
	int K; cin >> K;
	long A[100010];
	for(int i=0; i<K; ++i) cin >> A[i];
	long mn=2, mx=2;
	for(int i=K-1; i>=0; --i){
	    long s=(mn+A[i]-1)/A[i], l=mx/A[i];
	    if(s>l){
	        cout << -1 << endl;
	        return 0;
	    }
	    else mn=s*A[i], mx=(l+1)*A[i]-1;
	}
	cout << mn << ' ' << mx << endl;
	return 0;
}


Measured memory_bytes: 1024
from heapq import heappop,heappush,heapify
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7) 
 
n,m = map(int,input().split())
a = [int(x) for x in input().split()]
 
a_minus = [-x for x in a]
heapify(a_minus)
 
pop = lambda: -heappop(a_minus)
push = lambda x: heappush(a_minus,-x)
 
for _ in range(m):
    x = pop()
    push(x//2)
 
print(-sum(a_minus))

Measured memory_bytes: 14168
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;
const int MAXN = 1e6+10;
int a[MAXN];
int main()
{
	int n;
	scanf("%d",&n);
	for (int i =1;i<=n;i++)scanf("%d",&a[i]);

	
	sort(a+1,a+n+1);

	int sol = a[n/2+1]-a[n/2];
	cout<<sol<<endl;

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <bitset>
#include <tuple>
#include <cmath>
#include <complex>
#include <algorithm>
#include <utility>
#include <regex>
#include <cstdint>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
using ll = int64_t;
using ull = uint64_t;

constexpr ll INF = 1000000000;/* 1e+9a */
namespace utils{

    class Repeater{
        int st;
        int ed;
        int d;
    public:
        class rep_iterator{
            int i; int d;
        public:
            rep_iterator(int x, int pd) :i(x), d(pd) {}

            int& operator*(){ return i; }
            bool operator==(const rep_iterator& k) const { return i == k.i; }
            bool operator!=(const rep_iterator& k) const { return i != k.i; }
            rep_iterator& operator++(){ i+=d; return *this; }
        };

        explicit Repeater(int N) :st(0), ed(N), d(1) {}
        Repeater(int b, int e) :st(b), ed(e), d(1) {if(st > ed){ st--; ed--; d = -1; } }

        rep_iterator begin() const{ return rep_iterator(st, d); }
        rep_iterator end() const{ return rep_iterator(ed, d); }

    };

    template<class T, class Compare> using p_queue = priority_queue<T, vector<T>, Compare>;
    template<class T> using min_queue = p_queue<T, greater<T>>;
    template<class T> using max_queue = p_queue<T, less<T>>;

    template<class T> bool min_update(T& X, const T& A){ if(X > A) {X = A; return true;} return false; }
    template<class T> bool max_update(T& X, const T& A){ if(X < A) {X = A; return true;} return false; }
#define ALL(x) begin(x), end(x)
#define rALL(x) rbegin(x), rend(x)
}
using namespace utils;


void sub_main(istream &is) {
    ll N, K;
    is >> N >> K;
    if(!is) return;
    vector<bool> dp(K+1, false);
    vector<int> A(N);
    for (auto &&a : A) {
        is >> a;
    } // end a

    for (int i = 0; i < dp.size(); ++i) {
        dp[i] = false;
        for (auto &&a : A) {
            if(a > i) break;
            dp[i] = dp[i] || not dp[i-a];
        } // end a
    } // end i

    cout << (dp[K] ? "First" : "Second") << endl;


}

int main(int argc, char *argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(16) << scientific;
#ifdef DEBUG
    string test_cases = "test_K.txt";
    cerr << "DEBUG MODE" <<  endl;
    cerr << test_cases << " -->" << endl;
    auto fs = fstream(test_cases, fstream::in);
    int lp = 0;
    while(fs) {
        lp++;
        cout << lp <<  "#------\n";
        sub_main(fs);
    }
    cout << "------#" << endl;
    if(lp <= 1) sub_main(cin);
#else
    sub_main(cin);
#endif
    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	A := make([]int, N)
	B := make([]int, N)
	C := make([]int, N-1)

	for i := 0; i < N; i++ {
		fmt.Scan(&A[i])
	}
	for i := 0; i < N; i++ {
		fmt.Scan(&B[i])
	}
	for i := 0; i < N-1; i++ {
		fmt.Scan(&C[i])
	}

	ans := 0
	p := -999
	for i := 0; i < N; i++ {
		m := A[i] - 1
		ans += B[m]
		if m == p+1 {
			ans += C[p]
		}
		p = m
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	int n;
	int[] x;
	long[][][] dp;

	long dp(int k, int t, int s) {
		if (k < 0 || t < 0 || s < 0) {
			return 0;
		}
		if (k == 0) {
			if (t == 0 && s == 0) {
				return 1;
			}
			if (t == 1 && s == x[0]) {
				return 1;
			}
			return 0;
		}
		if (0 <= dp[k][t][s]) {
			return dp[k][t][s];
		}

		long ret = dp(k - 1, t, s);
		ret += dp(k - 1, t - 1, s - x[k]);
		return dp[k][t][s] = ret;
	}

	void run() {
		Scanner sc = new Scanner(System.in);

		n = sc.nextInt();
		int a = sc.nextInt();
		x = new int[n];
		for (int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
		}
		long ans = 0;
		dp = new long[n][n + 1][a * n + 1];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n + 1; j++) {
				Arrays.fill(dp[i][j], -1);
			}
		}
		for (int i = 1; i <= n; i++) {
			ans += dp(n - 1, i, a * i);
		}
		System.out.println(ans);
	}

	public static void main(String[] args) {
		new Main().run();
	}
}


Measured memory_bytes: 72616
n = int(input())
L = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14,
     1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(L[n-1])


Measured memory_bytes: 38384
#include<cstdio>
#include<cmath>
#include<iostream>
using namespace std;
int main(){
    int  a = 0;
    int  b = 0;
    int deg =0;
    double S =0.0;
    double L =0.0;
    double h =0.0;
    double rad =0.0;
    double PI =acos(-1);
    cin >> a >> b >> deg;
    rad = deg * PI / 180.0;
    S = a * b * sin(rad) / 2.0;
    h = b * sin(rad);
    L = a + b + sqrt(a*a+b*b-2*a*b*cos(rad));

    printf("%.7f\n",S);
    printf("%.7f\n",L);
    printf("%.7f\n",h);
     
    return 0;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;

int main(){ 
  double x;
  cin >> x;
  
  cout << setprecision(10);
  cout << x * x * x / 27 << endl;

}

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

int main(void)
{
  int H, W;
  std::cin >> H >> W;
  
  struct Point { int r,c; };
  std::vector<std::vector<int>> board(H);
  std::vector<Point> blacks;
  int white = 0;
  for(int i=0; i<H; i++)
  {
    for(int j=0; j<W; j++)
    {
      char c;
      std::cin >> c;
      board[i].push_back( c=='#' );
      if( c=='#' ) { blacks.push_back(Point{i,j}); }
      else { white += 1; }
    }
  }

  int count = 0;
  while( ! blacks.empty() )
  {
    std::vector<Point> blacksNext;
    for(const auto& b : blacks)
    {
      if( b.r != 0 && board[b.r-1][b.c] == 0)
      {
        board[b.r-1][b.c] = 1;
        blacksNext.push_back(Point{b.r-1,b.c});
      }
      if( b.r != H-1 && board[b.r+1][b.c] == 0)
      {
        board[b.r+1][b.c] = 1;
        blacksNext.push_back(Point{b.r+1,b.c});
      }
      if( b.c != 0 && board[b.r][b.c-1] == 0)
      {
        board[b.r][b.c-1] = 1;
        blacksNext.push_back(Point{b.r,b.c-1});
      }
      if( b.c != W-1 && board[b.r][b.c+1] == 0)
      {
        board[b.r][b.c+1] = 1;
        blacksNext.push_back(Point{b.r,b.c+1});
      }
    }
    if( blacksNext.empty() ) { break; }
    count += 1;
    blacks = blacksNext;
  }

  std::cout << count;
}



Measured memory_bytes: 16080
d = [[[-1, -1], [0, -1], [1, -1], [1, 0], [0, 1], [-1, 0]],
     [[-1,  0], [0, -1], [1,  0], [1, 1], [0, 1], [-1, 1]]]

w, h = gets.split.map(&:to_i)
fld = (h+2).times.map{ [false]*(w+2) }
(1..h).each do |i|
  gets.split(" ").each_with_index{ |e, j| fld[i][j+1] = true if e == "1" }
end

prt = (h+2).times.map{ [false]*(w+2) }
arr = []
arr << [0, 0]
prt[0][0] = true
until arr.empty?
  y, x = arr.pop
  d[y%2].each do |dy, dx|
    u = y + dy; v = x + dx
    next if u < 0 || u > h+1 || v < 0 || v > w+1
    if !fld[u][v] && !prt[u][v]
      prt[u][v] = true
      arr << [u, v]
    end
  end
end

fld = fld.flatten.zip(prt.flatten).map{|f,p| !(!f&p) }

sum = 0
((w+2)+1...(h+1)*(w+2)).each do |i|
  u, v = i.divmod(w+2)
  d[u%2].each{ |y, x| sum += 1 if !fld[(u+y)*(w+2)+v+x] } if fld[u*(w+2)+v]
end
p sum

Measured memory_bytes: 9384
using System;

namespace Submit
{
    class Program
    {
        static void Main(string[] args)
        {
            string a = Console.ReadLine();
            char[] b = a.ToCharArray();
            for (int i = 0; i < b.Length; i++)
            {
                if (b[i] <= 'z' && b[i] >= 'a') b[i] -= ' ';
                else if (b[i] <= 'Z' && b[i] >= 'A') b[i] += ' ';
            }
            Console.WriteLine(b);
        }
    }
}


Measured memory_bytes: 8796
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <cstdio>
#include <complex>
#include <numeric>
#include <string.h>
#include <random>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
double PI = 3.141592653589793238462643383279;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

int n, k, q;
int cnt[100000];

int main() {
    cin >> n >> k >> q;
    rep(i,q) {
        int a; cin >> a;
        a--;
        cnt[a]++;
    }
    rep(i,n) {
        if (q-cnt[i] >= k) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
}

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

using lint = long long;

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int a, b;
	cin >> a >> b;
	if ((double)(a+b)/2 != (a+b)/2) {
		cout << "IMPOSSIBLE\n";
		exit(0);
	}
	cout << (a + b)/2 << '\n';
}



Measured memory_bytes: 256
N, L = gets.split(' ').map(&:to_i)
a = []

(1..N).each do |i|
  a << L + i - 1
end

if L >= 0
  sum = a.inject(:+) - a.min
else # L が負
  if N + L > 0 # N のほうが大きい; 0 が含まれる
    sum = a.inject(:+)
  else # L のほうが大きい; 0 は含まれない
    sum = a.inject(:+) - a.max
  end
end

puts sum

Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;

long long func(long long x) {
	long long n = 1;
	for(int i = 1; i <= x / 2; i++) {
		if(x % i == 0) {
			n++;
		}
	}
	return n;
}

int main()
{
    long long N;
	cin >> N;
	
	// f(x);
	
	long long sum = 0;
	for(long long k = 1; k <= N; k++) {
		long long Y = N / k;
		long long g = Y * (Y + 1) * k / 2;
		sum += g;
	}
	
	printf("%lld\n", sum);
	
    return 0;
}


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

void preorder_walk(int node, vector<int> left, vector<int> right){
    if (node == -1) return;
    cout << ' ' << node;
    preorder_walk(left[node], left, right);
    preorder_walk(right[node], left, right);
}

void inorder_walk(int node, vector<int> left, vector<int> right){
    if (node == -1) return;
    inorder_walk(left[node], left, right);
    cout << ' ' << node;
    inorder_walk(right[node], left, right);
}

void postorder_walk(int node, vector<int> left, vector<int> right){
    if (node == -1) return;
    postorder_walk(left[node], left, right);
    postorder_walk(right[node], left, right);
    cout << ' ' << node;
}


int main()
{
    int n = 0;
    cin >> n;
    vector<int> parent(n);
    vector<int> left(n);
    vector<int> right(n);
    fill(parent.begin(), parent.end(), -1);
    fill(left.begin(), left.end(), -1);
    fill(right.begin(), right.end(), -1);
    
    int idx = 0, L = 0, R = 0;
    for (int i = 0; i != n; ++i){
        cin >> idx >> L >> R;
        left[idx] = L;
        right[idx] = R;
        if (L != -1) parent[L] = idx;
        if (R != -1) parent[R] = idx;
    }
    
    int root = find(parent.begin(), parent.end(), -1) - parent.begin();
    
    cout << "Preorder" << endl;
    preorder_walk(root, left, right);
    cout << endl;
    cout << "Inorder" << endl;
    inorder_walk(root, left, right);
    cout << endl;
    cout << "Postorder" << endl;
    postorder_walk(root, left, right);
    cout << endl;
    return 0;
}

Measured memory_bytes: 3124
def solve():
    N = input()
    K = int(input())
    l = len(N)
    dp = [[[0]*(K+2) for i in range(2)] for j in range(l+1)]
    dp[0][False][0] = 1 

    for i in range(l):
        for smaller in [False,True]:
            for k in range(K+1):
                for x in range(10 if smaller else int(N[i])+1):
                    if x == 0:
                        dp[i+1][smaller or (x < int(N[i]))][k] += dp[i][smaller][k]
                    else:
                        dp[i+1][smaller or (x < int(N[i]))][k+1] += dp[i][smaller][k]
    
    print(dp[l][False][K] + dp[l][True][K])

if __name__ == '__main__':
    solve()

Measured memory_bytes: 39920
N, K = map(int, input().split())
sunuke_and_sweets_cnt = [0] * N # index is sunuke, value is sweets count
for i in range(K):
  d = int(input())
  A = list(map(int, input().split()))
  for j in range(d):
    sunuke_and_sweets_cnt[A[j] - 1] += 1
ans = 0
for sweets in sunuke_and_sweets_cnt:
  if sweets == 0:
     ans += 1
print(ans)

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

#define ALL(a) (a).begin(), (a).end()
#define llong long long

using namespace std;

signed main(){
	string s; cin >> s;
	int ans = 0;
	for(auto e : s)if(e == '1')ans++;
	cout << ans << endl;

	return 0;
}



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

int main() {
  string s;
  cin >> s;
  string ans = "";
  for (int i = 0; i < s.length(); i++) {
    if (s.at(i) == '0') {
      ans.push_back('0');
    } else if (s.at(i) == '1') {
      ans.push_back('1');
    } else {
      if (!ans.empty()) {
        ans.erase(ans.length() - 1);
      }
    }
  }

  printf("%s", ans.c_str());
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int n,w[100];

    scanf("%d",&n);

    int i;

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

    int sum_a = 0;
    int sum_b = 0;
    int min= 10000;
    int s;

    for(i=0;i<n;i++)
    sum_b += w[i];

    for(i=0;i<n;i++)
    {
        sum_a += w[i];
        sum_b -= w[i];

        s = sum_a - sum_b;

        if(s < 0)
             s*= -1;

         if(s < min)
         {
            min=s;
         }

    }

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

    return 0;
}

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

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll x, y;
  cin >> x >> y;
  ll res = 1LL << 59;
  if (x <= y) res = min(res, y - x);
  if (-x <= y) res = min(res, y + x + 1);
  if (x <= -y) res = min(res, -y - x + 1);
  if (-x <= -y) res = min(res, -y + x + 2);
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n = II()
    a = LI()
    acc = list(itertools.accumulate(a))
    ans = inf
    for i in range(n - 1):
        ans = min(ans, abs(acc[n - 1] - acc[i] - acc[i]))
    print(ans)
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 91724
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>

int testcase_ends() {
  size_t n;
  scanf("%zu", &n);

  if (n == 0)
    return 1;

  int m=0;
  bool up=false, left=false, right=false;
  for (size_t i=0; i<n; ++i) {
    char buf[4];
    scanf("%s", buf);
    std::string f=buf;

    if (f[0] == 'l') {
      left = !left;
    } else {
      right = !right;
    }

    if (!up && left && right) {
      up = true;
      ++m;
    } else if (up && !left && !right) {
      up = false;
      ++m;
    }
  }

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

int main() {
  while (!testcase_ends()) {}
}



Measured memory_bytes: 2848
import sys
from collections import deque
input = sys.stdin.readline
N = int(input())
graph = [[] for _ in range(N)]
ab = [list(map(lambda x:int(x)-1, input().split())) for _ in range(N-1)]

col_max = 0
for i in range(N-1):
  a, b = ab[i]
  graph[a] += [b]
  graph[b] += [a]

for i in range(N):
  col_max = max(col_max, len(graph[i]))
print(col_max)

def bfs(s):
  q = deque([s])
  col = [-1]*N
  col[s] = 0
  edge_col = {}

  while q:
    c = 1
    u = q.pop()
    for v in graph[u]:
      if col[v] == -1:
        if c == col[u]:
          c += 1
        col[v] = c
        q.append(v)
        edge_col[(u, v)] = c
        edge_col[(v, u)] = c
        c += 1
  return edge_col

col = bfs(0)

for a, b in ab:
  print(col[(a, b)])

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

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

    int sum=0;
    vector<int>t(n);
    for (int i=0;i<n;i++) {
        cin>>t[i];
        sum+=t[i];
    }

    int m;
    cin>>m;

    vector<pair<int,int>>px(m);
    for (int i=0;i<m;i++) {
        int p,x;
        cin>>p>>x;
        px[i]=make_pair(p,x);
    }

    for (int i=0;i<m;i++) {
        int sum2=sum;
        sum2+=px[i].second-t[px[i].first-1];
        cout<<sum2<<endl;
    }
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))

def sort(N,A):
    for i in range(N):
        v = A[i]
        j = i-1
        while(j >= 0 and A[j] > v):
            A[j+1] = A[j]
            j -= 1
            A[j+1] = v
        pr(A)

def pr(list):
    n = len(list)
    for i in range(n):
        if i < n-1:
            print(list[i],end=" ")
        else:
            print(list[i],end="\n")

sort(N,A)



Measured memory_bytes: 5984
'use strict'
const main = arg => {
	const input = arg.trim().split("\n");
	let N = Number(input[0])
	let Xs = input.slice(1, input.length).map((x) => {
		return { 
			start : Number(x.split(' ')[0]) - Number(x.split(' ')[1]), 
			end: Number(x.split(' ')[0]) + Number(x.split(' ')[1])
		}
	})
	
	Xs.sort((a, b) => a.end - b.end)
	let out = []
	out.push(Xs[0])
	for(let i = 1; i < N; i++) {
		if(Xs[i] && Xs[i].start >= out[out.length - 1].end) {
			out.push(Xs[i])
		}
	}
	
	console.log(out.length)
}   

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 67244
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <typeinfo>
using namespace std;
using ll = long long;

int main() {
	
	ll n, x;
	cin >> n >> x;
	vector<ll> a(n);
	int num = 0;

	for (int i = 0; i < n; i++)
		cin >> a[i];
	sort(a.begin(), a.end());

	for (int i = 0; i < n; i++)
	{
		x -= a[i];
		if (x < 0)
			break;
		num++;
	}
	if (x > 0)
		num--;
	cout << num << endl;

}



Measured memory_bytes: 256
n=int(input())
oto=[]
count=0
for x in range(0,n):
  a,b=input().split()
  oto.append([a,b])
  oto[x][0]=float(oto[x][0])
  if oto[x][1]=="BTC":
      oto[x][0]=oto[x][0]*380000
  count+=oto[x][0]
print(count)

Measured memory_bytes: 3064
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function bsearch(a,x)
	l,r = 1, length(a)
	while l <= r
		m = l+div(r-l,2)
		if a[m] < x
			l = m+1
		else
			r = m-1
		end
	end
	return(l-1)
end

function main()
	a,b,q = readline() |> split |> parseMap
	s = Array{Int}(a)
	t = Array{Int}(b)
	for i in 1:a
		s[i] = readline() |> parseInt
	end
	for i in 1:b
		t[i] = readline() |> parseInt
	end
	for i in 1:q
		x = readline() |> parseInt
		ls = bsearch(s,x)
		lt = bsearch(t,x)
		lss = 0
		rss = 0
		ltt = 0
		rtt = 0
		if ls == 0
			lss = -10^10
		else
			lss = s[ls]
		end
		if lt == 0
			ltt = -10^10
		else
			ltt = t[lt]
		end
		if ls == a
			rss = 10^11
		else
			rss = s[ls+1]
		end
		if lt == b
			rtt = 10^11
		else
			rtt = t[lt+1]
		end
		println(min(max(abs(x-lss),abs(x-ltt)), max(abs(x-rss),abs(x-rtt)), 2*min(abs(x-rss),abs(x-ltt))+max(abs(x-rss),abs(x-ltt)), 2*min(abs(x-lss),abs(x-rtt))+max(abs(x-lss),abs(x-rtt))))
	end
end
main()

Measured memory_bytes: 154508
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
 
long long n, m, aw;
int main()
{
	scanf("%lld %lld", &n, &m);
	if(m > 2 * n) {
		m = m / 2;
		m = m - n;
		aw = m / 2 + n;
		printf("%lld\n", aw);
		return 0;
	}
	else {
		aw = m / 2;
		printf("%lld\n", aw);
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll =long long int;
constexpr ll mod = 1e12;
int main()
{
	int n; cin >> n;
	vector<int>a(n);
	for (auto& ele : a)cin >> ele;
	map<int, int>m; int i = 1;
	for (int j = 0; j < n; ++j) {
		if (a[j] == i) {
			m[i]++; i++;
		}
	}
	if (m.size() == 0)puts("-1");
	else cout << n - m.size();
	return 0;
}

Measured memory_bytes: 10368
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def MI(): return map(int, input().split())


def S(): return input()


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = {False: 'No', True: 'Yes'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


show_flg = True
show_flg = False


def main():
    N, W = MI()
    V = 10 ** 3 * N
    dp = [IINF] * (V + 1)
    w = [0] * N
    v = [0] * N
    dp[0] = 0

    for i in range(N):
        w[i], v[i] = MI()

    for i in range(N):
        dp_next = [IINF] * (V + 1)
        for j in range(V+1):
            dp_next[j] = min(dp_next[j], dp[j])
            if j + v[i] <= V:
                dp_next[j+v[i]] = min(dp[j] + w[i], dp_next[j+v[i]])
        #     print(dp_next)
        # print('===========')
        dp = dp_next

    ans = 0
    for i in range(V+1):
        if dp[i] != IINF and dp[i] <= W:
            ans = i

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 114700
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N;
        cin >> N;
        vll L(N);
        rep(i, 0, N) cin >> L[i];
        sort(all(L));
        ll ans = 0;
        rep(a, 0, N) {
                rep(b, a+1, N) {
                        ll tmp = L[a] + L[b];
                        ll pos = lower_bound(all(L), tmp) - L.begin();
                        pos -= 1;
                        if (pos > b)  {
                                ans += pos - b ;
                        }
                }
        }
        cout << ans << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
using namespace std;
int inf = 1000000000;

int main(void) {
  int n;
  cin >> n;
  int cnt = 0;
  vector< vector<int> > tmp;
  vector<int> a(3);
  cin >> a[0] >> a[1] >> a[2];
  sort(a.begin(), a.end());
  tmp.push_back(a);
  for(int i=1; i<n; i++){
    cin >> a[0] >> a[1] >> a[2];
    sort(a.begin(), a.end());
    bool f = true;
    for(int j=0; j<tmp.size(); j++){
      if( tmp[j] == a ){
        f = false;
        cnt++;
      }
    }
    if( f ) tmp.push_back(a);
  }
  cout << cnt << endl;

  return 0;
}

// EOF

Measured memory_bytes: 3228
n = int(input())
h = [int(i) for i in input().split()]
inf = 10**7
dp = [inf]*100005
dp[0] = 0
dp[1] = abs(h[0]-h[1])
for i in range(2,n):
    dp[i] = min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]))
print(dp[n-1])

Measured memory_bytes: 20352
#include <stdio.h>

int main(void)
{
	int x;
	int y;
	int a;
	
	scanf("%d %d", &x, &y);
	
	a = x % y;
	
	while (a != 0){
		x = y;
		y = a;
		a = x % y;
	}
	
	printf("%d\n", y);
	
	return (0);
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
int main()
{  int a,b;
   cin>>a>>b;
   int r=abs(a-b);
  int k=0; 
 if(a<b) 
     k=2*a+2*r;
 else
     k=2*b+2*r;
if(k<=16)
  cout<<"Yay!";
else
  cout<<":(";
}

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

#define ll long long
#define endl "\n"

bool brute(int n, vector <int> a){
	for (int el:a){
    	n-=(n%el);
    }
    if (n==2) return true;
    return false;
}

int main(){
	//
    //freopen("input.txt", "r", stdin);
    //
    ios::sync_with_stdio(0);
    cin.tie(0);

    int k;
    cin>>k;
    vector <int> a(k);
    vector <ll> ans_min(k+1), ans_max(k+1);
    ans_min[k]=(ll)2;
    ans_max[k]=(ll)2;
    for (int i=0; i<k; ++i){
    	cin>>a[i];
    }
    for (int i=k-1; i>=0; --i){
    	ans_min[i] = ((ans_min[i+1]+a[i]-1)/a[i]) * a[i];
    	ans_max[i] = ((ans_max[i+1]/a[i]) * a[i]) + a[i] - 1;
    	if (ans_min[i]>ans_max[i]) {cout<<-1; return 0;}
    }
    cout<<ans_min[0]<<" "<<ans_max[0];
}

Measured memory_bytes: 5280
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>
#include <iomanip>
#include <tuple>

using namespace std;
long long a[310][310];
const long long INF=1LL<<60;

int main(){
   int n;
   cin>>n;
   long long sum=0;
   for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
         cin>>a[i][j];
         sum+=a[i][j];
      }
   }

   for(int k=0;k<n;k++){
      for(int i=0;i<n;i++){
         for(int j=0;j<n;j++){
            if(a[i][j]>a[i][k]+a[k][j]){
               cout<<-1<<endl;
               return 0;
            }
         }
      }
   }
   for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
         for(int k=0;k<n;k++){
            if(k!=i && k!=j && a[i][j]==a[i][k]+a[k][j]){
               sum-=a[i][j];
               break;
            }
         }
      }
   }
   cout<<sum/2<<endl;



}

   


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;

int main(){
    int N;
    cin >> N;
    int A[3];
    int i=0;
    while(N>0){
        A[i] = N%10;
        N /= 10;
        i++;
    }
    int ans =0;
    for(int i=0;i<3;i++){
        if(A[i]==7)  ans++;
    }
    if(ans >0) cout << "Yes"<< endl;
    else cout << "No"<< endl;

}



Measured memory_bytes: 3676
#include "bits/stdc++.h"
#include<unordered_map>
#pragma warning(disable:4996)
using namespace std;

const int My_Inf = 2147483647;
const long long int My_LInf = 9223372036854775807;

struct plant {
	double fertrate;

	double lovewater;
	double vital;
};
double pw;
vector<plant>plants;

double getmon(const double water) {
	double ans = water*pw;
	for (auto p:plants) {
		double rest = p.vital - water*p.lovewater;
		if (rest < 0) {
			ans += 0;
		}
		else {
			ans += rest / p.fertrate;
		}
	}
	return ans;
}

int main() {
	while (1) {
		plants.clear();
		int N; cin >> N; if (!N)break;
		cin >> pw;
		for (int i = 0; i < N; ++i) {
			double vw, pf, vf, t; cin >> vw >> pf >> vf >> t;
			double fertrate = vf / pf;
			double water= vw;
			plants.push_back(plant{ fertrate,water,t });

		}
		double amin = 0;
		double amax = 100;
		while (amin < amax - 1e-13) {
			double amid1 = (amin * 2 + amax) / 3;
			double amid2 = (amin + amax * 2) / 3;
			double mon1 = getmon(amid1);
			double mon2 = getmon(amid2);
			if (mon1 < mon2) {
				amax = amid2;
			}
			else {
				amin = amid1;
			}
		}
		double ans = getmon((amin+amax)/2);
		cout <<setprecision(22)<<fixed<< ans << endl;
	}
	return 0;
}

Measured memory_bytes: 6020
#include <bits/stdc++.h>
using namespace std;
string S;
int main() {
    cin >> S;
    int len = S.length();
    int min = 1000000;
    for(int i = 0; i < len-2; ++i) {
        string str = S.substr(i, 3);
        int num = atoi(str.c_str());
        int ans = abs(num - 753);
        if(ans < min) min = ans;
    }

    cout << min << endl;
}

Measured memory_bytes: 764
/*
ID: skipian1
PROB: 
LANG: C++11
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF = 2000000000
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define X first
#define Y second

int main() {
  int n, x;
  cin >> n;
  int xr = 0;
  for (int i = 0; i < n; i++) {
    cin >> x;
    xr = xr^x;
  }
  if (xr == 0) cout << "Yes" << "\n";
  else cout << "No" << "\n";
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  int h, w;
  cin >> h >> w;
  vector<vector<bool > > mp(h, vector<bool>(w,false));
  char tmp;
  REP(i, h){
    REP(j, w){
      cin >> tmp;
      if(tmp =='#'){
	mp[i][j] = true;
      }
    }
  }
  vector<int> dh ={-1,1};
  vector<int> dw ={-1,1};
  int x, y;
  bool flag = false;
  bool ans = true;
  REP(i, h){
    REP(j, w){
      if(mp[i][j]){
	flag = false;
	REP(k, 2){
	  y = i + dh[k];
	  x = j;
	  if(0<=y&&y<h){
	    if(mp[y][x]){
	      flag = true;
	      break;
	    }
	  }
	}
	if(!flag){
	  REP(k, 2){
	    x = j + dw[k];
	    y = i;
	    if(0<=x&&x<h){
	      if(mp[y][x]){
		flag = true;
		break;
	      }
	    }
	  }
	}
	if(!flag){
	  cout << "No" << endl;
	  return 0;
	}
      }
    }
  }
  cout << "Yes" << endl;

}


Measured memory_bytes: 256
def snuke_coloring2(W: int, H: int, N: int, queries: list) -> int:
    # 白い領域の上下左右の値。
    u, d, r, l = H, 0, W, 0

    for x, y, a in queries:
        if a == 1:
            l = max(l, x)
        elif a == 2:
            r = min(r, x)
        elif a == 3:
            d = max(d, y)
        else:  # a == 4
            u = min(u, y)

    return max(r - l, 0) * max(u - d, 0)


if __name__ == "__main__":
    N = 0
    W, H, N = map(int, input().split())
    queries = [tuple(int(s) for s in input().split()) for _ in range(N)]
    ans = snuke_coloring2(W, H, N, queries)
    print(ans)


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

pub 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")
}

pub fn read_n<T: FromStr>(n: usize) -> Vec<T> {
  read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
  match n {
    0 => a,
    _ => {
      a.push(read::<T>());
      read_n_logic(n - 1, a)
    }
  }
}

use std::cmp::{max, min};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

fn divisors(N: i64) -> HashSet<i64> {
  let mut ds = vec![];
  let mut d = 1;
  while d * d <= N {
    if N % d == 0 {
      ds.push(d);
      ds.push(N / d);
    }
    d += 1;
  }
  let uniq: HashSet<i64> = ds.into_iter().collect();
  uniq
}

fn main() {
  let mut n: i64 = read();
  let mut m: i64 = read();
  let mut ans = 0;

  let yakusu = divisors(m);

  for i in yakusu {
    if i <= m / n {
      ans = max(ans, i)
    }
  }

  println!("{}", ans)
}

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

#define ll long long
#define ull unsigned long long 
#define endl '\n'
#define pii pair<int, int>
#define all(a) a.begin(),a.end()

int main(){
    int n, k, s;
    cin >> n >> k >> s;
    int x;
    if(s==1e9)
        x = 1;
    else
        x = s+1;

    for(int i=0; i<k; ++i){
        cout << s << " ";
    }
    for(int i=0; i<n-k; ++i){
        cout << x << " ";
    }
}


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff;
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; }
//template end



int main(){
    int n; scanf("%d",&n);
    if(n%2==0)printf("%d\n",n/2-1);
    else printf("%d\n",n/2);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define M_MAX 20
using namespace std;
int main(){
  int i,k,N,M,C,A[M_MAX],B[M_MAX];
  cin>>N>>M>>C;
  int sum,cnt=0;
  for(i=0;i<M;i++)cin>>B[i];
  
  for(i=0;i<N;i++){
    sum=0;
    for(k=0;k<M;k++){
      cin>>A[k];
      sum+=A[k]*B[k];
      }
    if(sum+C>0)cnt++;      
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main(){
    std::string s;
    std::cin >> s;
    unsigned long count = 0;
    for(char c : s){
        if(c == '1'){
            count++;
        }
    }
    int t = std::min(count, (s.length()-count));
    std::cout << t*2 << std::endl;

}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	ll n,k; cin>>n>>k;
	ll a[n];
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	ll ans=0;
	for(int i=0;i<k;i++) ans+=a[i];
	cout<<ans<<endl;


}


Measured memory_bytes: 3620
#include<stdio.h>
#include<string.h>
int main(){
  char a[1000],b[1000],c[1000];
  int n,t,i,j,A,l,sign;
  scanf("%d",&n);
  for(t=0;t<n;t++){
    scanf("%s %s",a,b);
    if(strlen(a)>80||strlen(b)>80){
      printf("overflow\n");
    }
    else if(strcmp(a,"0")==0&&strcmp(b,"0")==0){
      printf("0\n");
    }
    else {
      if(strlen(a)>strlen(b)){
	strcpy(c,a);
	strcpy(a,b);
	strcpy(b,c);
      }
      l=strlen(a);
      a[101]='\0';
      for(i=l-1,j=100;i>=0;i--,j--){
	a[j]=a[i];
      }
      for(;j>=0;j--){
	a[j]='0';
      }

      l=strlen(b);
      for(i=l-1,j=100;i>=0;i--,j--){
	a[j]+=(b[i]-'0');
	if(a[j]>'9'){
	  a[j-1]++;
	  a[j]=a[j]-10;
	}
      }
      if(a[20]!='0'){
	printf("overflow\n");
      }
      else{
	for(i=0,sign=0;i<=100;i++){
	  if(a[i]!='0'){
	    sign=1;
	  }
	  if(sign==1){
	    printf("%c",a[i]);
	  }
	}
      printf("\n");
      }
    }
  }
  return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
struct masivs{long long a;long long b;long long c;};
masivs mas[100005];
long long i,j,n,m,rez,sum;
multiset<long long> s;
multiset<long long>::iterator it;
int main()
{
    std::cin.sync_with_stdio(false);
    std::cin.tie(0);
    cin >> n >> m;
    i=0;
    while (i<n)
    {
        cin >> mas[i].a >> mas[i].b >> mas[i].c;
        i++;
    }
    s.clear();
    i=0;
    while (i<n)
    {
        s.insert(mas[i].a+mas[i].b+mas[i].c);
        i++;
    }
    i=0;
    it=s.end();
    it--;
    while (i<m)
    {
        rez+=*it;
        it--;
        i++;
    }
    sum=max(sum,abs(rez));
    rez=0;
    s.clear();
    i=0;
    while (i<n)
    {
        s.insert(mas[i].a+mas[i].b-mas[i].c);
        i++;
    }
    i=0;
    it=s.end();
    it--;
    while (i<m)
    {
        rez+=*it;
        it--;
        i++;
    }
    sum=max(sum,abs(rez));
    rez=0;
    s.clear();
    i=0;
    while (i<n)
    {
        s.insert(mas[i].a-mas[i].b+mas[i].c);
        i++;
    }
    i=0;
    it=s.end();
    it--;
    while (i<m)
    {
        rez+=*it;
        it--;
        i++;
    }
    sum=max(sum,abs(rez));
    rez=0;
    s.clear();
    i=0;
    while (i<n)
    {
        s.insert(mas[i].a-mas[i].b-mas[i].c);
        i++;
    }
    i=0;
    it=s.end();
    it--;
    while (i<m)
    {
        rez+=*it;
        it--;
        i++;
    }
    sum=max(sum,abs(rez));
    rez=0;
    s.clear();
    i=0;
    while (i<n)
    {
        s.insert(-mas[i].a+mas[i].b+mas[i].c);
        i++;
    }
    i=0;
    it=s.end();
    it--;
    while (i<m)
    {
        rez+=*it;
        it--;
        i++;
    }
    sum=max(sum,abs(rez));
    rez=0;
    s.clear();
    i=0;
    while (i<n)
    {
        s.insert(-mas[i].a+mas[i].b-mas[i].c);
        i++;
    }
    i=0;
    it=s.end();
    it--;
    while (i<m)
    {
        rez+=*it;
        it--;
        i++;
    }
    sum=max(sum,abs(rez));
    rez=0;
    s.clear();
    i=0;
    while (i<n)
    {
        s.insert(-mas[i].a-mas[i].b+mas[i].c);
        i++;
    }
    i=0;
    it=s.end();
    it--;
    while (i<m)
    {
        rez+=*it;
        it--;
        i++;
    }
    sum=max(sum,abs(rez));
    rez=0;
    s.clear();
    i=0;
    while (i<n)
    {
        s.insert(-mas[i].a-mas[i].b-mas[i].c);
        i++;
    }
    i=0;
    it=s.end();
    it--;
    while (i<m)
    {
        rez+=*it;
        it--;
        i++;
    }
    sum=max(sum,abs(rez));
    rez=0;
    cout << sum;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define N 5005
#define pll pair<ll,ll>

ll dp[N][N];

bool evaluate(vector<pll> &vt, ll idx, ll k){
	ll n = vt.size();
	memset(dp, 0, sizeof(dp));
	dp[0][0]=1;
	
	for(int i=0 ; i<n ; i++) { 
		for(int cur_sum = 0 ; cur_sum <=k ; cur_sum++){
			
			dp[i+1][cur_sum] = dp[i][cur_sum];
			
			ll cur = vt[i].first;
			if(cur <= cur_sum && i != idx){
				dp[i+1][cur_sum] |= dp[i][cur_sum-cur];
			}
			
		}
	}

	for(int i = max(0ll, k-vt[idx].first) ; i<= k-1 ; i++){
		if(dp[n][i]){
			return true;
		}
	}
	
	return false;
}

ll subset_sum(vector<pll> &vt, ll k){
	ll n = vt.size();
	ll s = 0;
	ll e = n-1;
	ll ans = -1;
	
	while(s<=e){
		ll mid = (s+e)/2;
		if(evaluate(vt, mid, k)==0){
			ans = mid;
			s = mid+1;
		} else {
			e = mid-1;
		}
	}
	
	return ans;
}


int main(){
	ll n, k;
	cin>>n>>k;
	vector<pll> a(n);
	for(ll i=0 ; i<n ; i++){
		cin>>a[i].first;
		a[i].second=i;
	}
	sort(a.begin(), a.end());
	ll val = subset_sum(a, k);
	cout<<val+1;
	return 0;
}

Measured memory_bytes: 196096