akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define int long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define PI acos(-1)
#define bp __builtin_popcountll
#define all(x) x.begin(),x.end()
#define sp fixed<<setprecision
#define pii pair<long long,long long>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int MOD = (1e9)+7;
const int N = 1e6+5;


int mpower(int x, int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1){
            res = (res*x) % p;
        }
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}

int comb(int n,int r)
{
    int num = 1;
    int den = 1;
    for(int i=1,j=n;i<=r;i++,j--)
    {
        den*=i;den%=MOD;
        num*=j;num%=MOD;
    }
    num*=mpower(den,MOD-2,MOD);num%=MOD;
    return num;
}

signed main()
{
    FAST
    int tc=1;
    //cin>>tc;
    for(int ti=1;ti<=tc;ti++)
    {
        int x,y;
        cin>>x>>y;
        int s = x+y;
        if(s%3)return cout<<0,0;
        int n = ((2*x)-y)/3;
        int m = ((2*y)-x)/3;
        if(n<0 || m<0)return cout<<0,0;
        else cout<<comb(n+m,min(n,m))<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
def dfs(i, sum, count, nokori):
    global ans
    if i == d:
        # G 点に満たなければ nokori のうち一番大きいものを解く
        if sum < g:
            use = max(nokori)
            # 解く問題が問題数を超えないように注意
            n = min(pc[use - 1][0], -(-(g - sum) // (use * 100)))
            count += n
            sum += n * use * 100

        if sum >= g:
            ans = min(ans, count)
    else:
        # 総合スコア、解いた問題数、まだ解いてない問題を更新
        dfs(i + 1, sum, count, nokori)
        dfs(i + 1, sum + pc[i][0] * (i + 1) * 100 + pc[i][1], count + pc[i][0], nokori - {i + 1})


d, g = map(int, input().split())
pc = [list(map(int, input().split())) for i in range(d)]

ans = float("inf")

dfs(0, 0, 0, set(range(1, d + 1)))
print(ans)

Measured memory_bytes: 3064
<?php
fscanf(STDIN, '%d %d', $N, $K);

$num = $N;
$digits = 1;
while (true) {
    $num = intval(floor($num / $K));
    if ($num === 0) {
        break;
    }
    $digits++;
    if ($num === 1) {
        break;
    }
}

echo $digits;

echo PHP_EOL;


Measured memory_bytes: 16012
from collections import Counter

N = int(input())
A = list(map(int, input().split()))

c = Counter(A)
eat = 0
for v in c.most_common():
  if v[1] >= 2:
    eat += v[1] - 1

if eat % 2 != 0:
  eat += 1
  
print(N-eat)

Measured memory_bytes: 21980
s = input()
j = -1
k = -1
for i in range(0, len(s) - 1):
    if s[i] == s[i + 1]:
        j, k = i + 1, i + 2
        break
    elif i + 2 < len(s) and s[i] == s[i + 2]:
        j, k = i + 1, i + 3
        break
print(str(j) + ' ' + str(k))

Measured memory_bytes: 3188
#[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)*}
    };
}

#[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 search(i: usize, j: usize, h: usize, w: usize, ss: &Vec<Vec<char>>, seen: &mut Vec<Vec<bool>>, c: char, c1: &mut usize, c2: &mut usize) {
    if seen[i][j] {
        return;
    }

    if ss[i][j] != c {
        return;
    }

    if c == '#' {
        *c1 += 1;
    } else {
        *c2 += 1;
    }

    seen[i][j] = true;

    let i = i as isize;
    let j = j as isize;
    let h = h as isize;
    let w = w as isize;

    let ds = [
        [1,0],
        [-1,0],
        [0,1],
        [0,-1],
    ];

    for d in ds.iter() {
        let dx = d[0];
        let dy = d[1];
        if i + dx < 0 || i + dx >= h {
            continue;
        }

        if j + dy < 0 || j + dy >= w {
            continue;
        }
        search((i+dx) as usize, (j+dy) as usize, h as usize, w as usize, ss, seen, if c == '#'  { '.' } else { '#' }, c1, c2);
    }
}

fn main() {
    input!{
      h: usize,
      w: usize,
      ss: [chars; h],
    }
    let ss = ss;


    let mut seen = vec![vec![false; w]; h];
    let mut ans = 0usize;
    for i in 0..h {
        for j in 0..w {
            if !seen[i][j] {
                let mut c1 = 0;
                let mut c2 = 0;
                if ss[i][j] == '#' {
                    search(i, j, h, w, &ss, &mut seen, '#', &mut c1, &mut c2);
                    ans += c1 * c2;
                }
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 19324
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <memory>
#include <cstring>
#include <cassert>
#include <numeric>
#include <sstream>
#include <complex>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#define REP2(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(S) (S).begin(), (S).end()

template <typename T, typename E>
ostream &operator<<(std::ostream &os, const std::pair<T, E> &p){
  return os << "(" << p.first << ", " << p.second << ")";
}

typedef long long ll;

void bfs(const vector<vector<int> > &G, vector<int> &D, int S, pair<int, int> NG){
#define IS_NG(a, b) ((NG == make_pair(a, b)) || (NG == make_pair(b, a)))

  fill(ALL(D), G.size() + 1);

  D[S] = 0;
  queue<int> que;
  que.push(S);
  while (!que.empty()){
    int v = que.front(); que.pop();
    for (auto w : G[v]){
      if (!IS_NG(v, w) && D[w] > D[v] + 1){
        D[w] = D[v] + 1;
        que.push(w);
      }
    }
  }
}

int main(){
  ios::sync_with_stdio(false);

  int W, H, N;
  cin >> W >> H >> N;
  vector<vector<int> > G(W * H);
  vector<int> D(W * H);

  vector<int> SX(N), SY(N), DX(N), DY(N);
  
  REP(i, N){
    cin >> SX[i] >> SY[i] >> DX[i] >> DY[i];
  }
  
  REP(x, W) REP(y, H){
    if (x < W - 1) {
      bool ok = true;
      REP(i, N) if (SX[i] == x + 1 && DX[i] == x + 1){
        if (min(SY[i], DY[i]) <= y && y < max(SY[i], DY[i])) ok = false;
      }
      if (ok){
        G[x + y * W].push_back(x + 1 + y * W);
        G[x + 1 + y * W].push_back(x + y * W);
      }
    }

    if (y < H - 1) {
      bool ok = true;
      REP(i, N) if (SY[i] == y + 1 && DY[i] == y + 1){
        if (min(SX[i], DX[i]) <= x && x < max(SX[i], DX[i])) ok = false;
      }
      if (ok){
        G[x + y * W].push_back(x + (y + 1) * W);
        G[x + (y + 1) * W].push_back(x + y * W);
      }
    }
  }

  int ix, iy, ox, oy;
  cin >> ix >> iy >> ox >> oy;
  bfs(G, D, ix + iy * W, make_pair(-1, -1));

  int dist = D[ox + oy * W];
  int best = D[ox + oy * W];
    
  REP(v, W * H){
    for (auto w : G[v]){
      bfs(G, D, ix + iy * W, make_pair(v, w));

      if (D[ox + oy * W] <= W * H){
        best = max(best, D[ox + oy * W]);
      }
    }
  }
  cout << best - dist << endl;
  return 0;
}

Measured memory_bytes: 1348
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て
// next_permutation(all(x))

int		main(void)
{
	int N, X;
	cin >> N >> X;

	int ans = 1, P = 0;
	for (int i = 0; i < N; i++)
	{
		int L;
		cin >> L;
		P += L;
		if (P <= X)
			ans++;
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

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

	private void solve() throws IOException {
		try {
			solveA();
			//			 solveB();
			//			 solveC();
			//			 solveD();
			//			 solveE();
			//			 solveF();
		} finally {
			if (in != null) {
				in.close();
			}
			if (out != null) {
				out.flush();
				out.close();
			}
		}

	}

	private void solveA() {
		int numX = nextInt();
		int numA = nextInt();
		int numB = nextInt();

		if (numA >= numB) {
			out.println("delicious");
		} else if (numA + numX >= numB) {
			out.println("safe");
		} else if (numA + numX < numB) {
			out.println("dangerous");
		}

	}

	private void solveB() {
		int numN = nextInt();

		out.println("");
	}

	private void solveC() {
		int numN = nextInt();

		out.println("");
	}

	private void solveD() {
		int numN = nextInt();

		out.println("");
	}

	private void solveE() {
		int numN = nextInt();

		out.println("");
	}

	private void solveF() {
		int numN = nextInt();

		out.println("");
	}

	private final PrintWriter out = new PrintWriter(System.out);
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

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

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
}

Measured memory_bytes: 21204
from statistics import median
n = int(input())
A = list(map(int, input().split()))
B = [(A[i]-(i+1)) for i in range(n)]

def calc_sad(b):
  ret = 0
  for i in range(n):
    ret += abs(B[i]-b)
  return ret

b = median(B)
sad = int(calc_sad(b))
print(sad)


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

int main() {
  int n;
  cin >> n;
  int64_t s = 0;
  vector<int> v(n);
  for(int i = 0; i < n; i++)
    cin >> v.at(i);
  for(int i = 0; i < n-1; i++){
    for(int j = i + 1; j < n; j++)
      s += v.at(i) * v.at(j);
  }
  cout << s << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

int dp[301][301][301];
vector<P>v[301];
void add(int&a, int b) {
	if (a == -1 || b == -1)return;
	(a += b) %= MOD;
}
signed main() {
	int n, m; scanf("%d%d", &n, &m);
	rep(i, m) {
		int l, r, x; scanf("%d%d%d", &l, &r, &x);
		v[r].push_back(P(l, x));
	}
	rep(i, n + 1)rep(j, n + 1)rep(k, n + 1) {
		for (P p : v[max({ i, j, k })]) {
			int cnt = 0;
			if (i >= p.first)cnt++;
			if (j >= p.first)cnt++;
			if (k >= p.first)cnt++;
			if (cnt != p.second)dp[i][j][k] = -1;
		}
	}
	add(dp[1][0][0], 1); add(dp[0][1][0], 1); add(dp[0][0][1], 1);
	rep(i, n)rep(j, i)rep(k, i) {
		if (j&&j == k)continue;
		add(dp[i + 1][j][k], dp[i][j][k]);
		add(dp[i][i + 1][k], dp[i][j][k]);
		add(dp[i][j][i + 1], dp[i][j][k]);

		add(dp[i + 1][i][k], dp[j][i][k]);
		add(dp[j][i + 1][k], dp[j][i][k]);
		add(dp[j][i][i + 1], dp[j][i][k]);

		add(dp[i + 1][k][i], dp[j][k][i]);
		add(dp[j][i + 1][i], dp[j][k][i]);
		add(dp[j][k][i + 1], dp[j][k][i]);
	}
	int ans = 0;
	rep(i, n)rep(j, n) {
		if (!i || i != j) {
			add(ans, dp[n][i][j]);
			add(ans, dp[i][n][j]);
			add(ans, dp[i][j][n]);
		}
	}
	printf("%d\n", ans);
}

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

int main() {
    int n;
    long long a[100001];
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    a[n++] = 0;
    sort(a, a+n);
    for(int i=1;i<n;i++){
        a[i] += a[i-1];
    }
    int ng = 0, ok = n-1;
    while(ng + 1 < ok){
        int mid = (ng + ok) / 2;
        bool f = true;
        for(int i=mid+1;i<n;i++){
            if(a[i] > a[i-1]*3){
                f = false;
                break;
            }
        }
        if(f){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    cout << n - 1 - ng << endl;
	return 0;
}

Measured memory_bytes: 1024
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#include <bits/stdc++.h>
using namespace std;

const bool ready = [](){
    ios_base::sync_with_stdio(false); cin.tie(0);
    cout << fixed << setprecision(12);
    return true;
}();

const double PI = acos(-1);
using ll= long long;
#define int ll
#define all(v) (v).begin(), (v).end()
#define fori(n) for(int i=0; i<int(n); i++)

#define cini(i) int i; cin>>i;
#define cins(s) string s; cin>>s;
#define cind(d) double d; cin>>d;
#define cinai(a,n) vi a(n); fori(n) { cin>>a[i]; }
#define cinas(s,n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a,n) vd a(n); fori(n) { cin>>a[i]; }

using pii= pair<int, int>;
using pdd= pair<double, double>;
using vd= vector<double>;
using vb= vector<bool>;
using vi= vector<int>;
using vvi= vector<vi>;
using vs= vector<string>;

int lcm(int a, int b) {
    return b*a/__gcd(a,b);
}
void solve() {
    cini(x);
    int deg=lcm(x,360);
    int ans=deg/x;
    cout<<ans<<endl;
}

signed main() {
    solve();
}

// FIRST THINK, THEN CODE
// DO NOT JUMP BETWEEN PROBLEMS


Measured memory_bytes: 3644
#!/usr/bin/env python3

x1, y1, x2, y2 = list(map(int, input().split()))

grad_x = x2-x1
grad_y = y2-y1

x3, y3 = x2-grad_y, y2+grad_x

x4, y4 = x3-grad_x, y3-grad_y

print(x3, y3, x4, y4)


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

int N,ans = 0;

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

	cin >> N;

	vector<int> H(N);
	//vector<int> T(N,0);

	for(auto &x : H){
		cin >> x;
	}

	while(1){
		bool f = true,a = false;
	
		REP(i,N){
			if(H[i]) a = true;

			if(a){
				if(H[i] == 0){
					ans++;
					a = false;
				}else{
					f = false;
					H[i] = H[i] - 1;
					if(i == N - 1) ans++;
				}
			
			}
		}
		
		if(f) break;
		
	}

	cout << ans << endl;

}

Measured memory_bytes: 256
/*
   Author : tarang
*/
#include<bits/stdc++.h>
#define ll long long
#define fastio ios_base::sync_with(false); cin.tie(0);cout.tie(0);
const int MOD = 1000000007;
#define PI = acos(-1)
using namespace std ;
int a[106];
int main(){
    int n ; cin >> n ;
    map<int,int>mp;
    vector<int> v(n);
    for(int i  =0 ; i<n ; i++){
    	 cin >> v[i];
	}
	int count = 0 ;
	for(int i = 0 ; i < n ; i++){
		 if(v[i]!= i+1){
		 	continue ;
		 }
		 else{
		 	swap(v[i] , v[i+1]);
		 	count++;
		 } 
	}
	cout << count << endl;
}

Measured memory_bytes: 3776
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (ll i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define Rev(a) reverse(a.begin(), a.end())
#define MATHPI acos(-1)
#define itn int
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-19;





signed main() {
    ll x;
    cin >> x;
    
    for (ll a = 0; a <= 1000; a++) {
        for (ll b = -1000; b <= 1000; b++) {
            if (a*a*a*a*a - b*b*b*b*b == x) {
                dmes (a, b);
                re0;
            }
        }
    }
    
    
    
    
    
    
    
    
    
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)
using P =pair<int,int>;

ll f(ll x,ll c,ll d){
    ll res =x;
    res -=x/c;
    res -=x/d;
    res+= x/lcm(c,d);
    return res;
}

int main(){
   ll n;
   cin>>n;
   vector<ll>v(5);
   rep(i,5)cin>>v[i];
   ll mi=1000000000000000;
   rep(i,5)mi=min(v[i],mi);
   
   if(n%mi==0){
       cout<<5+n/mi-1<<endl;
   }else{
       cout<<5+n/mi<<endl;
   }
}


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

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

	int ans = 0;
	for (auto p : m)
	{
		if (p.second >= p.first)
			ans += p.second - p.first;
		else
			ans += p.second;
	}
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 4260
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var num = ToInt32(ReadLine());
        var a = Array.ConvertAll(ReadLine().Split(' '), long.Parse);
        var b = Array.ConvertAll(ReadLine().Split(' '), long.Parse);
        var sum = a.Sum();
        var reg = b.Sum();
        if (reg > sum) { WriteLine(-1);return; }
        var dif = sum-reg;
        var w = new long[num];
        var count = 0L;
        var res = 0L;
        for(var i = 0; i < num; i++)
        {
            if (a[i] < b[i]) { res++; w[i] = long.MaxValue; }
            else { w[i] = a[i]-b[i]; count++; }
        }
        Array.Sort(w);
        for(var i = 0; i < num; i++)
        {
            if (dif >= w[i])
            {
                dif -= w[i];
            }
            else
            {
                WriteLine(count - i+res);
                return;
            }
        }
        WriteLine(0);
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}


Measured memory_bytes: 34396
N = int(input())
A = list(map(int,input().split()))
s = A[0]
c = 1
ans = 0
for a in A[1:]:
    if a == s:
        c += 1
    else:
        ans += c//2
        s = a
        c = 1
ans += c//2
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
#define w1 first
#define w2 second
#define ls (x<<1)
#define rs (x<<1|1)
#define pb push_back
#define mid ((l+r)>>1)
#define SZ(x) ((x).size())
#define All(x) (x).begin(),(x).end()
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define per(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define Rep(p,x) for(int (p)=head[(x)];(p);(p)=nxt[(p)])
template<class T>void read(T&num){
	num=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
	num*=f;
}
const int maxn=1e2+5;
int n,D,cnt[maxn];
int main(){
	read(n);
	rep(i,1,n){
		int x;read(x);
		D=max(D,x);
		cnt[x]++;
	}
	if(D%2==0){
		rep(i,1,D/2-1)if(cnt[i])return puts("Impossible"),0;
		if(cnt[D/2]>1)return puts("Impossible"),0;
		rep(i,D/2+1,D)if(cnt[i]<2)return puts("Impossible"),0;
	}else{
		rep(i,1,D/2)if(cnt[i])return puts("Impossible"),0;
		if(cnt[D/2+1]!=2)return puts("Impossible"),0;
		rep(i,D/2+2,D)if(cnt[i]<2)return puts("Impossible"),0;
	}
	puts("Possible");
	return 0;
}

Measured memory_bytes: 256
// ????????????????????°??????: ??£??\?????????

// Library
#include<vector>
#include<queue>
#include<functional>
#include<algorithm>
#include<cassert>
// Type
typedef int Vertex;
typedef int Weight;
struct Edge {
  Vertex from, to;
  Weight weight;
};
bool operator<(const Edge& lhs, const Edge& rhs) {
  if(lhs.weight != rhs.weight) return lhs.weight < rhs.weight;
  if(lhs.from != rhs.from) return lhs.from < rhs.from;
  return lhs.to < rhs.to;
}
bool operator>(const Edge& lhs, const Edge& rhs) {
  if(lhs.weight != rhs.weight) return lhs.weight > rhs.weight;
  if(lhs.from != rhs.from) return lhs.from > rhs.from;
  return lhs.to > rhs.to;
}
// Class
class Graph {
public:
  explicit Graph(int size);
  void add(const Vertex& from, const Vertex& to, const Weight& weight = 1);
  const std::vector<Edge> minimum_spanning_tree() const;
private:
  int size_;
  std::vector<std::vector<Edge>> edge_;
};
// Implement
Graph::Graph(int size) : size_(size), edge_(size) {
}
void Graph::add(const Vertex& from, const Vertex& to, const Weight& weight) {
  edge_.at(from).push_back({from, to, weight});
  edge_.at(to).push_back({to, from, weight});
}
// Minimum Spanning Tree: Prim's algorithm, O(|E| + |V| log |V|)
const std::vector<Edge> Graph::minimum_spanning_tree() const {
  if(size_ == 1) return {};
  assert(std::all_of(std::begin(edge_), std::end(edge_), [](const std::vector<Edge>& list){return !list.empty();}));
  std::vector<Edge> result;
  std::priority_queue<Edge, std::vector<Edge>, std::greater<Edge>> q(std::begin(edge_.front()), std::end(edge_.front()));
  std::vector<bool> visited(size_, false);
  visited.front() = true;
  while(!q.empty()) {
    auto current = q.top();
    q.pop();
    if(visited.at(current.to)) continue;
    visited.at(current.to) = true;
    result.push_back(current);
    for(const auto& e: edge_.at(current.to)) if(!visited[e.to]) q.push(e);
  }
  assert(result.size() == size_ - 1);
  return result;
}

#include<bits/stdc++.h>
using namespace std;
int main() {
  int V, E;
  cin >> V >> E;
  Graph g(V);
  for(int i = 0; i < E; ++i) {
    int s, t, w;
    cin >> s >> t >> w;
    g.add(s, t, w);
  }
  auto mst = g.minimum_spanning_tree();
  cout << accumulate(begin(mst), end(mst), 0, [](int sum, Edge e){return sum + e.weight;}) << endl;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main () {
    int ans = 0;
    ll N, D;
    cin >> N >> D;
    for (int i = 0; i < N; i++) {
        ll X, Y;
        cin >> X >> Y;
        if (X*X+Y*Y <= D*D) {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3616
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;

ll mod = 1000000007;

vi memo(2001, -1);

ll inverse(ll i) {
  if (memo[i] >= 0) return memo[i];

  // i の mod - 2乗
  ll ret = 1;
  ll j = mod - 2;
  ll k = i;
  while (j) {
    if (j % 2) {
      ret = ret * k % mod;
    }
    k = k * k % mod;
    j /= 2;
  }

  return memo[i] = ret;
}

ll c(ll x, ll y) {
  ll ret = 1;
  for (ll i = 1; i <= x; i++) {
    ret = ret * i % mod;
  }
  for (ll i = 1; i <= y; i++) {
    ret = ret * inverse(i) % mod;
  }
  for (ll i = 1; i <= x - y; i++) {
    ret = ret * inverse(i) % mod;
  }
  return ret;
}

int main() {
  ll n, k;
  cin >> n >> k;

  vi v1, v2;
  for (ll i = 0; i <= k - 1; i++) {
    v1.push_back(c(k - 1, i));

  }

  for (ll i = 0; i <= n - k + 1; i++) {
    v2.push_back(c(n - k + 1, i));
  }

  for (ll i = 1; i <= k; i++) {
    if (i > n - k + 1) cout << 0 << endl;
    else cout << v1[i - 1] * v2[i] % mod << endl;
  }

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define N 505
#define inf 1000000005
#define mod 998244353
#define put putchar('\n')
#define F(i,a,b) for (int i=a;i<=b;i++)
#define D(i,a,b) for (int i=a;i>=b;i--)
#define go(i,t) for (int i=head[t];i;i=Next[i])
#define sqr(x) ((x)*(x))
#define re register
#define mp make_pair
#define fi first
#define se second
#define M 10000005
#define pa pair <int,int>
using namespace std;
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
	int x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void wr(ll x){if (x<0) {putchar('-');wr(-x);return;}if(x>=10)wr(x/10);putchar(x%10+'0');}
inline void wrn(ll x){wr(x);put;}inline void wri(ll x){wr(x);putchar(' ');}
inline void wrn(ll x,ll y){wri(x);wrn(y);}
int n,m,a[N][N];
char str[N];
signed main(){
	n=read();m=read();
	F(i,1,n){
		scanf("%s",str+1);
		F(j,1,m) a[i][j]=((str[j]=='.')?0:3);
	}
	F(i,1,n) a[i][1]|=1,a[i][m]|=2;
	F(i,1,n){
		F(j,2,m-1){
			if (i&1) a[i][j]|=1;
			else a[i][j]|=2;
		}
	}
	F(i,1,n){
		F(j,1,m){
			if (a[i][j]&1) putchar('#');
			else putchar('.');
		}
		put;
	}
	put;
	F(i,1,n){
		F(j,1,m){
			if (a[i][j]&2) putchar('#');
			else putchar('.');
		}
		put;
	}
	return 0;
}

Measured memory_bytes: 1664
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main() {
    let ab:Vec<i32> = read_vec();
    let ans = (ab[0]..ab[1] + 1).filter(|x|{
        let ori = x.to_string().chars().collect::<Vec<char>>();
        let mut rev = ori.clone();
        rev.reverse();
        rev == ori
    }).count();
    println!("{}",ans);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    string s;
    cin>>s;
    reverse(btoe(s));
    int n=s.length(), a=1;
    vector<int> p(n+5);
    p[0]=s[0]-'0';
    rep(i,n-1){
        a*=10;
        a%=2019;
        p[i+1]=(a*(s[i+1]-'0')+p[i])%2019;
    }
    map<int,int> mp;
    rep(i,n) mp[p[i]]++;
    ll ans=0;
    for(auto& v: mp){
        if(v.first==0 && v.second!=0){
            ans+=(v.second+1)*v.second/2;
        }
        else{
            if(v.second>1) ans+=v.second*(v.second-1)/2;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

int main()
{
	int t;
	t=1;
	while(t--)
	{
	
	string s="ACL";
	
	int k;
	
	int i;
	
	cin>>k;
	
	for(i=0;i<k;i++)
	cout<<s;
	
	
	
	}



}


Measured memory_bytes: 3596
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))

struct edge{int to,cost;};
typedef pair<ll, int> P;//最短距離、頂点番号
vector<edge> G[105];
ll d[10005];

ll dist(int from, int to){
	priority_queue<P, vector<P>, greater<P> > que;
	fill(d,d+10005,LINF);
	d[from] = 0;
	que.push(P{0,from});
	while(!que.empty()){
		P p=que.top();que.pop();
		int v = p.second;
		if(d[v] < p.first) continue;
		rep(i,G[v].size()){
			edge e = G[v][i];
			if(d[e.to] > d[v] + e.cost){
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to],e.to));
			}
		}
	}
	return d[to];
}

int main(void){
	int n,m,a,b,c;
	cin>>n>>m;
	vector<edge> edges;
	rep(i,m){
		cin>>a>>b>>c;
		G[a].push_back(edge{b,c});
		G[b].push_back(edge{a,c});
	}
	int ans = 0;
	reps(i,n){
		rep(j,G[i].size()){
			//cout<<i<<" "<<G[i][j].to<<" "<<dist(i,G[i][j].to)<<endl;
			if(dist(i,G[i][j].to) < G[i][j].cost) ans++;
		}
	}
	cout<<ans/2<<endl;
	return 0;
}


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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

template <typename T>
void precision_cout(T x, int n, bool is_endl = false) {
    cout << fixed << setprecision(n) << x;
    if (is_endl) cout << endl;
}

template <typename T>
T gcd(T a, T b) {
    if (b == 0)
        return a;

    return gcd(b, a % b);
}

template <typename T>
T lcm(T a, T b) {
    return (a * b) / gcd(a, b);
}

template <typename T>
T radian(T angle) {
    return angle * M_PI / 180.0;
}

void solve() {
    int n;
    cin >> n;

    int count = 0;
    while ((n + count) % 1000 != 0)
        count++;

    cout << count << endl;
}

int main() {
    solve();

    return 0;
}


Measured memory_bytes: 3624
H,W = map(int,input().split())
A = [input().strip() for _ in range(H)]
C = {}
for i in range(H):
    for j in range(W):
        a = A[i][j]
        if a not in C:
            C[a] = 0
        C[a] += 1
if H==1 or W==1:
    if H*W%2==0:
        flag = 0
        for a in C:
            if C[a]%2==1:
                flag = 1
                break
        if flag==0:
            print("Yes")
        else:
            print("No")
    else:
        cnt = 0
        for a in C:
            if C[a]%2==1:
                cnt += 1
        if cnt==1:
            print("Yes")
        else:
            print("No")
elif H%2==0 and W%2==0:
    flag = 0
    for a in C:
        if C[a]%4>0:
            flag = 1
            break
    if flag==0:
        print("Yes")
    else:
        print("No")
elif H%2==0:
    cnt = 0
    flag = 0
    for a in C:
        if C[a]%2==1:
            flag = 1
            break
        if C[a]%4==2:
            cnt += 1
    if flag==1:
        print("No")
    else:
        if cnt<=H//2:
            print("Yes")
        else:
            print("No")
elif W%2==0:
    cnt = 0
    flag = 0
    for a in C:
        if C[a]%2==1:
            flag = 1
            break
        if C[a]%4==2:
            cnt += 1
    if flag==1:
        print("No")
    else:
        if cnt<=W//2:
            print("Yes")
        else:
            print("No")
else:
    cnt1 = 0
    cnt2 = 0
    for a in C:
        if C[a]%2==1:
            cnt1 += 1
        if C[a]%4==2:
            cnt2 += 1
    if cnt1!=1:
        print("No")
    else:
        if cnt2<=(H+W-2)//2:
            print("Yes")
        else:
            print("No")

Measured memory_bytes: 65716
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <functional>

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

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

int main(){
  ll n;
  cin >> n;
  ll v[n];
  rep(i, n) cin >> v[i];

  ll cnt[2][100001] = {};
  rep(odd, 2) rep(i, n/2) cnt[odd][v[2*i+odd]]++;
  P first[] = {P(-1, 0), P(-1, 0)};
  P second[] = {P(-1, 0), P(-1, 0)};
  rep(odd, 2) rep(i, 100001){
    if(first[odd].second < cnt[odd][i]){
      second[odd] = first[odd];
      first[odd] = P(i, cnt[odd][i]);
    }
    else if(second[odd].second < cnt[odd][i]){
      second[odd] = P(i, cnt[odd][i]);
    }
  }

  ll ans;
  if(first[0].first != first[1].first) ans = n - first[0].second - first[1].second;
  else if(second[0].second < second[1].second) ans = n - first[0].second - second[1].second;
  else ans = n - first[1].second - second[0].second;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>


using namespace std;

#define ll long long
#define ld long double
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}

const double PI=acos(-1);
const double EPS=1e-9; //うまくいかなかったらゆるめる
typedef complex<double> P;
typedef vector<P> G;
#define shosu(x) fixed<<setprecision(x)
#define diff(P,i) (P[(i+1)%P.size()] - P[i])

struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
  L(){;}
};
struct C {
  P c;double r;
  C(const P &c,double r):c(c),r(r){}
  C(){;}
};

namespace std{//演算子の定義
  bool operator < (const P& a,const P& b) {
    return real(a)!= real(b) ? real(a) < real(b) : imag(a) < imag(b);
    //return imag(a) != imag(b) ? imag(a) < imag(b) : real(a) < real(b)
  }
  bool operator == (const P& a,const P& b) {
    return a.real()==b.real() && a.imag()==b.imag();
  }
}


void printP(const P &p){
  cout << shosu(10) << p.real() << " " << p.imag() << endl;
}

void printL(const L &l) {
  	cout << shosu(10) << l[0].real() << " " << l[0].imag() << " " << l[1].real() << " " << l[1].imag() << endl;
}

void printG(const G &g) {
  for(int i = 0; i < g.size(); i++){
    cout << shosu(10) << g[i].real() << " " << g[i].imag() << endl;
  }
}



double dot(P a,P b) {
  return real(conj(a)*b);
}

double cross(P a,P b) {
  return imag(conj(a)*b);
}


L crosspointCC(C a,C b){ //2円の交点
	P tmp = b.c - a.c;
	double d = abs(tmp);
	double q = acos((a.r * a.r + d * d - b.r * b.r)/(2 * a.r * d));
	double t = arg(tmp);//atan(tmp.imag()/tmp.real());
	P p1 = a.c + polar(a.r, t + q);
	P p2 = a.c + polar(a.r, t - q);
	if(p2 < p1) swap(p1,p2);
	return L(p1, p2);
}


double distancePP(const P &p, const P &q){ //2点間の距離
  return hypot(p.real()-q.real(), p.imag()-q.imag());
}

P inP(){
  double x,y;
  scanf("%lf,%lf", &x, &y);
  //cin >> x >> y;
  P p(x,y);
  return p;
}

C inC(){
  P p = inP();
  double r = 1.0;
  C c(p,r);
  return c;
}



signed main(void) {
    int n;
    while(cin >> n, n){
        vector<C> v(n);
        rep(i,n)v[i] = inC();
        int ans = 1;
        rep(i,n)loop(j,i+1,n){
            if(distancePP(v[i].c, v[j].c) > 2)continue;
            L l = crosspointCC(v[i],v[j]);
            vi t(2);
            rep(k,n)if(k != i && k != j){
                rep(x,2)if(distancePP(l[x],v[k].c) <= 1 + EPS)t[x]++;
            }
            ans = max(ans, max(t[0],t[1])+2);
        }
        cout << ans << endl;
    }
}



Measured memory_bytes: 3616
macro_rules! input {
    ($x:expr) => {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        $x = buf.trim().parse().unwrap();
    };

    ($x:expr, $($y:expr), +) => {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).ok();
        input_iter!(buf.split_whitespace(), $x, $($y), +);
    };

    ($v:expr; $size:expr) => {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).ok();
        for v in buf.split_whitespace() {
            $v.push(v.parse().unwrap());
        }
    };

    ($v:expr; $h_size:expr, $w_size:expr) => {
        for _ in 0..$h_size {
            let mut part_vec = Vec::new();
            let mut buf = String::new();
            std::io::stdin().read_line(&mut buf).ok();
            for v in buf.split_whitespace() {
                part_vec.push(v.parse().unwrap());
            }
            $v.push(part_vec);
        }
    };
}

#[allow(unused_macros)]
macro_rules! input_iter {
    ($iter:expr, $x:expr) => {
        $x = $iter.next().unwrap().parse().unwrap();
    };

    ($iter:expr, $x:expr, $($y:expr), +) => {
        let mut iter = $iter;
        $x = iter.next().unwrap().parse().unwrap();
        input_iter!(iter, $($y), *);
    };
}

fn main() {
    let mut _a: i32;
    let mut _b: i32;
    let mut _t: i32;
    input!(_a, _b, _t);
    println!("{}", _b * (_t / _a));
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define ll long long 
#define mp make_pair 
#define f(i,n) for(int i=0;i<n;i++) 
#define F first 
#define S second 
#define pb push_back 

using namespace std;

void test(){
	ll a,b,c;
	cin>>a>>b>>c;
	ll k;
	cin>>k;
	ll cnt = 0;
	while(b<=a){
		b = b*2;
		cnt++;
	}
	while(c<=b){
		c = c*2;
		cnt++;
	}
	if(cnt<=k)cout<<"Yes\n";
	else cout<<"No\n";
}

int main(){
	int tests=1;
	// cin>>tests;
	while(tests--){
		test();
	}
}


Measured memory_bytes: 3592
//ITP1_4_D Min,Max and Sum

#include<stdio.h>
int main(void) {

	int n, a[10000],max=-1000000,min=1000000,i;
	long sum=0;

	scanf("%d", &n);

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

		if (a[i] < min)
			min = a[i];

		sum=a[i]+sum;


	}
	printf("%d %d %ld\n", min, max, sum);
	
	return 0;

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;

ll powa(ll a, ll b, ll c)
{
    a%=c;
    if(a<0)
	a+=c;
    ll res = 1;
    while(b>0)
    {
        if(b&1)
            res*=a, res%=c;
        a*=a, a%=c;
        b>>=1;
    }
    return res;
}

#define N 200005
 
ll fact[N];
ll ifact[N];

ll ncr(ll n, ll r)
{
    if(r>n)
        return 0;
    ll ans = fact[n];
    ans*=ifact[r];
    ans%=mod;
    ans*=ifact[n-r];
    ans%=mod;
    return ans;
}
int main()
{
   FAST/**/
   
   fact[0] = 1;
   for(ll i=1;i<N;i++)
        fact[i] = fact[i-1]*i, fact[i]%=mod;
   for(ll i=0;i<N;i++)
        ifact[i] = powa(fact[i],mod-2,mod);
   
   ll k,q;
   cin>>k>>q;
   ll arr[k];
   rep(k)
        cin>>arr[i];
   while(q--)
   {
       ll n,x,m;
       cin>>n>>x>>m;
       
       ll arr1[k];
       rep(k)
            arr1[i] = arr[i]%m;
       ll sum = 0;
       rep(k)
            sum+=arr1[i];
       
       ll pref[k];
       pref[0] = arr1[0];
       for(ll i=1;i<k;i++)
            pref[i] = pref[i-1] + arr1[i];
       
       ll rem = (n-1)%k;
       
       ll mini = (x%m);
       ll maxi = (x%m) + (sum*((n-1)/k));
       if(rem>0)
            maxi += pref[rem-1];
       //cout<<"maxi = "<<maxi<<"\n";
       ll st = 1;
       ll en = maxi/m;
       ll tot = en - st + 1;
       ///cout<<"tot = "<<tot<<"\n";
       tot = max(0ll,tot);
       ll ans = n-1-tot;
       rep(k)
       {
            if(arr1[i] == 0)
            {
                if(n-1-i-1<0)
                    continue;
                ll temp = (n-1-i-1)/k;
                //cout<<"temp = "<<temp<<"\n";
                temp = temp+1;
                temp = max(temp,0ll);
                ans-=temp;
            }
       }
       cout<<ans<<"\n";
       
   }
   
   return 0;        
}  
   

Measured memory_bytes: 3584
'use strict';

const main = arg => {
    const input = arg.trim().split('\n').map(Number);		//Each line (l) of input is input[l]

    if (input.indexOf(1) === -1) {
        console.log(1);
    } else if (input.indexOf(2) === -1) {
        console.log(2);
    } else {
        console.log(3);
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
long bignum = 1_000_000_007;
alias Works = Tuple!(long, "require", long, "limit");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    auto n = lread();
    auto w = new Works[](n);
    foreach (i; 0 .. n)
    {
        long a, b;
        scan(a, b);
        w[i] = Works(a, b);
    }
    w.sort!"a.limit < b.limit"();
    long timesum;
    bool check = true;
    foreach (e; w)
    {
        timesum += e.require;
        if(timesum > e.limit)
            check = false;
    }
    if(check)
        writeln("Yes");
    else
        writeln("No");
}


Measured memory_bytes: 5884
import itertools

A = int(input())
B = int(input())
C = int(input())
X = int(input())

available_prices = [500 * a + 100 * b + 50 * c for a, b, c in itertools.product(range(A+1), range(B+1), range(C+1))]
 
cnt = 0
for p in available_prices:
    if p == X:
        cnt += 1

print(cnt)

Measured memory_bytes: 8404
require 'pp'
h,w,k = gets.split.map(&:to_i)

s = []
h.times do
  s << gets.chomp.chars
end
# pp s
# puts s.map(&:join).join("\n")


c = Array.new(h){Array.new(w,0)}
num = 0
h.times do |hh|
  next if s[hh].all?{|ss|ss == '.'}
  w.times do |ww|
    if s[hh][ww] == "#"
      num += 1
      c[hh][ww] = num
    end
  end
end

# puts c.map{|cc|cc.map{|ccc|sprintf('%3d|',ccc)}.join}.join("\n")

h.times do |hh|
  next if s[hh].all?{|ss|ss == '.'}
  w.times do |ww|
    if c[hh][ww] == 0
      c[hh][ww] = c[hh][ww-1] if 0 <= ww-1
    end
  end
  w.times do |ww|
    if c[hh][w-ww-1] == 0
      c[hh][w-ww-1] = c[hh][w-ww] if w-ww < w
    end
  end
end

# puts c.map{|cc|cc.map{|ccc|sprintf('%3d|',ccc)}.join}.join("\n")


h.times do |hh|
  w.times do |ww|
    if c[hh][ww] == 0
      hhh = hh
      until c[hhh][ww] != 0
        hhh += 1
        if hhh >= h
          until (hhh < h) && c[hhh][ww] != 0
            hhh -= 1
          end
          break
        end
      end
      n = c[hhh][ww]
      c[hh][ww] = n
    end
  end
end

# puts c.map{|cc|cc.map{|ccc|sprintf('%3d|',ccc)}.join}.join("\n")
puts c.map{|cc|cc.join(' ')}.join("\n")


Measured memory_bytes: 11900
#include<stdio.h>
int main(void)
{
    long long int n,k,a,b,c;
    scanf("%lld %lld",&n,&k);
    a = n % k;
    b = k - a;
    if(a < b)
    {
        printf("%lld",a);
        return 0 ;
    }
    else
    {
        printf("%lld",b);
        return 0 ;
        
    }
    
    return 0 ;
}

Measured memory_bytes: 1720
#include <iostream>

int main() {
	unsigned long long int a, b, c;
	std::cin >> a >> b >> c;
	if (a + b > c) std::cout << "No\n";
	else {
		if (4 * a * b < (c - a - b) * (c - a - b)) std::cout << "Yes\n";
		else std::cout << "No\n";
	}
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
ll F(ll a, ll b) {
  int keta1 = 0, keta2 = 0;
  while (0 < a) {
    keta1++;
    a /= 10;
  }
  while (0 < b) {
    keta2++;
    b /= 10;
  }
  return max(keta1, keta2);
}
int main() {
  ll N;
  cin >> N;
  queue<pair<ll, ll>> q{};
  for (ll i = 1; i <= ceil(sqrt(N)); i++) {
    ll j = N / i;
    if (i * j == N) {
      q.push(pair<ll, ll>(i, j));
    }
  }
  ll mn = 1e+15;
  while (!q.empty()) {
    pair<ll, ll> p = q.front();
    q.pop();
    mn = min(mn, F(p.first, p.second));
  }
  cout << mn << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String args[]){
		Scanner sc=new Scanner(System.in);
		int N = sc.nextInt(); // # of shops
		int[][] F = new int[N][10];
		int[][] P = new int[N][11];
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < 10; j++) F[i][j] = sc.nextInt();
		}
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < 11; j++) P[i][j] = sc.nextInt();
		}
		int ans = Integer.MIN_VALUE;
		for(int i = 1; i < (1 << 10); i++) {
			int[] c = new int[N];
			for(int j = 0; j < N; j++) {
				// 店jと一致する時間帯を計算
				for(int k = 0; k < 10; k++) {
					if(((i >> k) & 1) == 1 && F[j][k] == 1) c[j]++;
				}
			}
			int tmp = 0;
			for(int j = 0; j < N; j++) tmp += P[j][c[j]];
			ans = Math.max(ans, tmp);
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 25920
import java.util.*;
import java.io.*;
 
public class Main{
  public static void main(String[] args)throws Exception{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    try{
      int N = Integer.parseInt(br.readLine());
      String S = br.readLine();
      long r = 0, g = 0, b = 0;
      for(int i = 0; i < N; i++){
        char c = S.charAt(i);
        if(c == 'R'){
          r++;
        }else if(c == 'G'){
          g++;
        }else{
          b++;
        }
      }
      
      long ans = r * g * b;
      for(int i = 0; i < N; i++){
        char c1 = S.charAt(i);
        for(int j = i+1; j < N; j++){
          if(j+(j-i) >= N) break;
          char c2 = S.charAt(j);
          char c3 = S.charAt(j+(j-i));
          if(c1 != c2 && c2 != c3 && c1 != c3){
            ans--;
          }
        }
      }
      System.out.println(ans);
    }catch(Exception e){
      System.out.println(e.toString());
    }
  }
}


Measured memory_bytes: 32804