akhauriyash/Code-Regression huggingface dataset:
from collections import Counter

n, k, q = map(int, input().split())
a = [int(input()) for _ in range(q)]
c = Counter(a)
for i in range(1, n + 1):
    if i in c:
        if (k - q + c[i]) > 0:
            print("Yes")
        else:
            print("No")
    else:
        if k - q > 0:
            print("Yes")
        else:
            print("No")


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

using namespace std;

#define REP(var, n)  for (decltype(n) var = 0; var < (n); var++)
#define RREP(var, n)  for (auto var = n - 1; var != static_cast<decltype(var)>(-1); var--)
#define FOR(var, a, b)  for (auto var = (a); var < (b); var++)
#define RFOR(var, a, b)  for (auto var = b - 1; var != a; var--)

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

#define all(c) begin(c),end(c)

template<typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
    if (!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}

auto solve() {
    int H, W;
    cin >> H >> W;
    vector<string> purple(H);
    for (auto &&r : purple) cin >> r;

    vector<string> red(H, string(W, '.')), blue(H, string(W, '.'));
    red[0] = string(W, '#');
    blue[H - 1] = string(W, '#');
    REP(c, W) {
        FOR(r, 1, H - 1) {
            if (c % 2 == 0) {
                red[r][c] = '#';
            } else {
                blue[r][c] = '#';
            }
        }
    }

    REP(i, H)cerr << red[i] << endl;
    cerr << endl;
    REP(i, H)cerr << blue[i] << endl;
    cerr << endl;
    cerr << endl;

    REP(r, H) {
        REP(c, W) {
            if (purple[r][c] == '#') {
                if (c % 2 == 0) {
                    blue[r][c] = '#';
                } else {
                    red[r][c] = '#';
                }
            }
        }
    }

    REP(i, H)cout << red[i] << endl;
    cout << endl;
    REP(i, H)cout << blue[i] << endl;
}

int main() {
//    cout << solve() << endl;
    solve();
    return 0;
}


Measured memory_bytes: 1536
#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define INF 1e9
using ll = std::int64_t;

template <class T>
bool chmax(T &a, const T &b);
template <class T>
bool chmin(T &a, const T &b);
//最大公約数
std::int64_t gcd(std::int64_t a, std::int64_t b);
std::int64_t gcd_s(std::int64_t aa, std::int64_t bb);
//ラングレス圧縮
std::vector<std::pair<char, std::int64_t>> rle(std::string str);
//素数判定
bool is_prime(std::int64_t n);
// 約数の列挙
std::vector<std::int64_t> divisor(std::int64_t n);
// 素因数分解
std::map<std::int64_t, std::int64_t> prime_factor(std::int64_t n);

//10^9 + 7
#define yojo 1000000007
#define MAX_NUM 200001

void Main()
{
  int a, b, c, x;
  cin >> a >> b >> c >> x;
  int count = 0;
  rep(i, a + 1){
    rep(j, b + 1){
      rep(k, c + 1){
        if (500 * i + 100 * j + 50 * k == x)
        {
          count++;
        }
      }
    }
  }

  std::cout << count << std::endl;

  return;
}

int main()
{
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}

template <class T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}

template <class T>
bool chmin(T &a, const T &b)
{
  if (b < a)
  {
    a = b;
    return true;
  }
  return false;
}

//最大公約数
std::int64_t gcd(std::int64_t a, std::int64_t b)
{
  // a >= b && b != 0
  std::int64_t c;
  do
  {
    c = a % b;
    a = b;
    b = c;
  } while (c);

  return a;
}

//最大公約数安全版
std::int64_t gcd_s(std::int64_t aa, std::int64_t bb)
{
  std::int64_t a = max(aa, bb);
  std::int64_t b = min(aa, bb);
  std::int64_t c;
  if (b == 0)
  {
    return -1;
  }
  do
  {
    c = a % b;
    a = b;
    b = c;
  } while (c);

  return a;
}

//ラングレス圧縮
std::vector<std::pair<char, std::int64_t>> rle(std::string str)
{
  std::vector<std::pair<char, std::int64_t>> data;
  char now = str[0];
  std::int64_t count = 0;
  for (std::int64_t i = 0; i < str.size() + 1; i++)
  {
    if (i == str.size())
    {
      data.push_back(make_pair(str[i - 1], count));
      break;
    }
    else if (now != str[i])
    {
      data.push_back(make_pair(now, count));
      now = str[i];
      count = 0;
    }
    count++;
  }

  return data;
}

//素数判定
bool is_prime(std::int64_t n)
{
  for (std::int64_t i = 0; i * i <= n; i++)
  {
    if (n % i == 0)
    {
      return false;
    }
  }

  return n != 1;
}

//約数の列挙
std::vector<std::int64_t> divisor(std::int64_t n)
{
  std::vector<std::int64_t> res;
  for (int i = 0; i < n; i++)
  {
    if (n % i == 0)
    {
      res.push_back(i);
      if (i != n / i)
        res.push_back(n / i);
    }
  }
  return res;
}

// 素因数分解
std::map<std::int64_t, std::int64_t> prime_factor(std::int64_t n)
{
  std::map<std::int64_t, std::int64_t> res;
  for (int i = 2; i * i <= n; i++)
  {
    while (n % i == 0)
    {
      ++res[i];
      n /= i;
    }
  }

  if (n != 1)
  {
    res[n] = 1;
  }

  return res;
}

Measured memory_bytes: 256
n, s = map(int, input().split())
a = list(map(int, input().split()))
MOD = 998244353

dp = [[[0] * (s + 1) for i in range(2)] for i in range(n + 1)]
dp[0][0][0] = 1


# 最後に選ぶとき 1
# 最後に選ばないとき 0
for i in range(n):
    for j in range(s + 1):
        # 選ぶとき
        if j + a[i] <= s:
            dp[i + 1][1][j + a[i]] += dp[i][0][j] + dp[i][1][j]
            dp[i + 1][1][j + a[i]] %= MOD
        # 選ばないとき
        dp[i + 1][0][j] += (dp[i][0][j] + dp[i][1][j]) * 2
        dp[i + 1][0][j] %= MOD
ans = 0
for i in range(n + 1):
    ans += dp[i][1][-1] * pow(2, (n - i), MOD)
    ans %= MOD
print(ans)
 
    

Measured memory_bytes: 210812
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1LL << 60;

template <typename T>
void print(const T &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
}

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

    ll ans = 0;
    int tmp = 0;
    for (int a = 1; a <= n; a++)
    {
        int b = n / a; // bは1以上になる
        int c = n - (a * b);
        if (c == 0)
        {
            --b; // 過剰にカウントした分を減らす
        }
        if (b >= a)
        {
            // cout << a << ':' << b << endl;
            ++tmp;
        }
        ans += b;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3672
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
using namespace std;
typedef long long int ll;
const int N = 1000000;
const ll INF = std::numeric_limits<long long>::max();
#define rep(i,n) for(ll i=(ll)0;i<(ll)n;++i)
#define ALL(x) x.begin(),x.end()
#define pp pair<ll,ll>
#define fi first
#define se second
#define sz size
string YN(bool b) { return(b ? "YES" : "NO"); }
string yn(bool b) { return(b ? "Yes" : "No"); }
ll n, m;
pp pos[100], chpos[100];
int main() {
	cin >>n>>m ;
	rep(i, n)cin >> pos[i].fi >> pos[i].se;
	rep(i, m)cin >> chpos[i].fi >> chpos[i].se;
	rep(i, n) {
		ll min = INF, minj = 0;
		rep(j, m) {
			ll l = abs(pos[i].fi - chpos[j].fi) + abs(pos[i].se - chpos[j].se);
			if (l < min) { min = l; minj = j; }
		}
		cout << minj+1<< endl;
	}
	return 0;
}

Measured memory_bytes: 256
#import numpy as np
n = int(input())
a = list(map(int,input().split()))
base = [0]*n
ans = 0

for i in range(n):
  if a[i] > n:
    ans += 1
  else:
    base[a[i]-1] += 1
    
for i in range(n):
  if base[i] == 0:
    continue
  elif base[i] == i+1:
    continue
  elif (base[i] < i+1) and (0 < base[i]):
    ans += base[i]
  elif i+1 < base[i]:
    ans += (base[i] - (i+1))
    
print(ans)

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

int main(){
    string str; cin >> str;
    int n = str.size();
    int s[n];
    for(int i=0;i<n;i++) s[i] = str[i]-'0';

    char op[n-1];
    int sum;
    for(int bit=0;bit<(1<<n-1);bit++){
        sum = s[0];
        for(int i=0;i<n-1;i++){
            if(bit & (1<<i)){
                sum += s[i+1];
                op[i] = '+'; 
            }
            else{
                sum -= s[i+1];
                op[i] = '-';
            }
        }
        if(sum == 7) break;
    }
    cout<<s[0]<<op[0]<<s[1]<<op[1]<<s[2]<<op[2]<<s[3]<<'='<<sum;
}


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

#define Max 10000
const long long INF = 1LL << 60;

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<long long>h(N+1),dp(N + 1);


	for (int i = 1; i <= N; i++)
	{
		cin >> h[i];
	}
	dp[1] = 0;
	dp[2] = abs(h[2]-h[1]);
	for (int j = 3; j <= N; j++)
	{
		dp[j] = min(dp[j-2] + abs(h[j] - h[j-2]), dp[j-1] + abs(h[j] - h[j-1]));
	}
	cout << dp[N];
}




Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
using namespace std;
int main() {
    string s,t;
    cin >> s >> t;
    int flag = 0;

    for(int i = 0;i < s.length();i++){
        if(s.at(i) != t.at(i)){
            flag = 1;
        }
    }

    if(flag == 1){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }

    return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<cctype>
using namespace std;

int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	string s;
	cin>>s;
	if(s[0]==s[2])cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	
	return 0;
}

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

using namespace std;

int house[10][10];
int m, n;
int nh=0;
int charch[2];
int saiki(int x, int y, int N)
{
    if(N==0){
        if(x==charch[0] || y == charch[1]) return 1;
        else return 0;
    }
    else
    {
        int sum=0;
        for(int i=x-1;i>=0;--i)
        {
            if(house[i][y] == 1)
            {
                house[i][y] = 0;
                sum += saiki(i, y, N-1);
                house[i][y] = 1;
                break;
            }
        }
        for(int i=x+1;i<m;++i)
        {
            if(house[i][y] == 1)
            {
                house[i][y] = 0;
                sum += saiki(i, y, N-1);
                house[i][y] = 1;
                break;
            }
        }
        for(int i=y-1;i>=0;--i)
        {
            if(house[x][i] == 1)
            {
                house[x][i] = 0;
                sum += saiki(x, i, N-1);
                house[x][i] = 1;
                break;
            }
        }
        for(int i=y+1;i<n;++i)
        {
            if(house[x][i] == 1)
            {
                house[x][i] = 0;
                sum += saiki(x, i, N-1);
                house[x][i] = 1;
                break;
            }
        }
        return sum;
    }

}
int main()
{
    while(cin >> m >> n && m && n)
    {
        for(int j=0;j<n;++j){
            for(int i=0;i<m;++i)
            {
                cin >> house[i][j];
                if(house[i][j] == 1) ++nh;
                else if(house[i][j] == 2)
                {
                    charch[0] = i;
                    charch[1] = j;
                }
            }
        }
        cout << saiki(charch[0], charch[1], nh) << endl;
        nh = 0;
    }
}

Measured memory_bytes: 1156
#include <iostream>
using namespace std;
typedef long long LL;
const LL MOD=1e9+7;
LL mpow(LL a,LL x){
    if(x==0)return 1;
    LL t=mpow(a,x>>1);
    if(x%2==0)return t*t%MOD;
    return t*t%MOD*a%MOD;
}
LL gcd(LL x,LL y){
    return y==0?x:gcd(y,x%y);
}
LL n,m,t;
int main() {
    cin>>n>>m>>t;
    LL h=n/gcd(n,t);
    LL w=m/gcd(m,t);
    LL c=(n*m)/(h*w);
    LL x=(mpow(2,gcd(h,w))+mpow(2,h)+mpow(2,w)-3+MOD)%MOD;
    cout<<mpow(x,c)<<endl;
}

Measured memory_bytes: 256
def is_ok(index):
  s=0
  for i in range(p-1,index):
    s+=a[index]+m-a[i]
  return s+m*(n-index+p-1)>=m*v and a[index]+m>=a[p-1]
def binary_search(a):
  ok=-1
  ng=len(a)
  while abs(ng-ok)>1:
    mid=(ng+ok)//2
    if is_ok(mid):ok=mid
    else:ng=mid
  return ok+1
n,m,v,p=map(int,input().split())
a=sorted(list(map(int,input().split())))[::-1]
print(binary_search(a))


Measured memory_bytes: 86908
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef vector<int> vec;
//配列の添字ズレに注意
int main(){
  ll a,b,c,k,ans; cin>>a>>b>>c>>k;
  
  //if(k<=a)ans=a;
  if(k<=a+b)ans=min(k,a);
  else ans=2*a-k+b;

  cout<<ans<<endl;
}


Measured memory_bytes: 3636
import sys
import heapq
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    N = int(input())
    s = set()
    q = [0, 0]
    for a in map(int, input().split()):
        if a > q[0]:
            try:
                s.remove(a)
                heapq.heapreplace(q, a)
            except:
                s.add(a)
    print(q[0]*q[1])


if __name__ == '__main__':
    main()


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

ll N, M;
ll A[MAX_N] = {};
map<ll, ll> Mod;

signed main()
{
    cin >> N >> M;
    ll sum = 0;
    Mod[0] = 1;
    REP(i, N) {
        cin >> A[i];
        sum += A[i];
        sum %= M;
        Mod[sum]++;
    }

    ll ans = 0;
    for(auto& m : Mod) {
        if(m.second > 1) {
            ans += m.second * (m.second - 1) / 2;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  int h, n;
  cin >> h >> n;
  vi a(n), b(n);
  rep(i, n) cin >> a[i] >> b[i];
  vvi dp(n + 1, vi(h + 5, INF));
  rep(i, n) dp[i][0] = 0;
  rep(i, n) rep(j, h + 1) {
    mins(dp[i + 1][j], dp[i][j]);
    if (j - a[i] < 0)
      mins(dp[i + 1][j], b[i]);
    else
      mins(dp[i + 1][j], dp[i + 1][j - a[i]] + b[i]);
    // dumpv(dp, n + 1, h + 1);
  }
  cout << dp[n][h] << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 39424
// dile a la jardinera que traigo flores

#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define sz(x) int(x.size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define FER(i,a,b) for(int i = int(a); i < int(b); ++i)
#define IFR(i,a,b) for(int i = int(a); i >= int(b); i--)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;


int main(){	
	fastio;
	vector<int>masks;
	int n,m;cin>>n>>m;
	FER(i,0,n){
		int val=0;
		int k;cin>>k;
		FER(i,0,k){
			int lel;cin>>lel;
			lel--;
			val+=(1<<lel);
		}
		masks.pb(val);
	}
	int ans=(1LL<<31)-1;
	FER(i,0,n)ans=ans&masks[i];
	cout<<__builtin_popcount(ans)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int A, B;
	cin >> A >> B;

	cout << max(A + B, max(A - B, A * B)) << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
/* "It's okay if you hate me. I hate me too." */

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;

const int maxN = (int)1E5+5;

int n, m;
int a[maxN];
int d[maxN];
int t[maxN];

int main() {
	scanf("%d %d", &n, &m);
	for (int i = 0; i < n; ++i) {
		scanf("%d", &a[i]);
		--a[i];
	}
	memset(d, 0, sizeof(d));
	for (int i = 1; i < n; ++i)
		d[a[i]] += ((a[i]-a[i-1]+m)%m)-1;
	memset(t, 0, sizeof(t));
	for (int i = 1; i < n; ++i) if ((a[i]-a[i-1]+m)%m > 1) {
		if (a[i] > a[i-1]) {
			--t[a[i]];
			++t[a[i-1]+1];
		}
		else {
			--t[m];
			++t[a[i-1]+1];
			--t[a[i]];
			++t[0];
		}
	}
	for (int i = 1; i < m; ++i)
		t[i] += t[i-1];
	LL res = 0;
	for (int i = 1; i < n; ++i)
		if (a[i] > a[i-1])
			res += (a[i]-a[i-1]);
		else
			res += a[i]+1;
	LL minres = res;
	for (int i = 1; i < m; ++i) {
		res += d[i-1];
		res -= t[i-1];
		minres = min(res, minres);
	}
	cout << minres << endl;
	return 0;
}


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

int main() {
	ll n, k;
	cin >> n >> k;
	vector<ll> a(n);
	for (ll i = 0; i < n; ++i)cin >> a[i];
	ll Min = 0;
	ll Max = 1e10;
	while (Max - Min > 1) {
		ll Mid = (Min + Max) / 2;
		ll sum = 0;
		for (ll i = 0; i < n; ++i) {
			sum += (a[i] - 1) / Mid;
		}
		if (sum <= k)Max = Mid;
		else Min = Mid;
	}
	cout << Max << endl;
}


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

using namespace std;

string S, T;
int s_size;
map<char, vector<int> > s_map, t_map;
set<vector<int> > s_index_set, t_index_set;
string YES = "Yes", NO = "No";

void map_values_to_set(bool is_s) {
    map<char, vector<int> > str_map = is_s ? s_map : t_map;
    set<vector<int> > index_set;

    map<char, vector<int> >::iterator it;
    for (it = str_map.begin(); it != str_map.end(); it++) {
        index_set.insert(it->second);
    }
    
    if (is_s) {
        s_index_set = index_set;
    } else {
        t_index_set = index_set;
    }
}

void map_indexes_to_c(bool is_s) {
    string str = is_s ? S : T;
    map<char, vector<int> > str_map;

    for(int i = 0; i < s_size; i++) {
        char c = str[i];
        if (str_map.count(c) > 0) {
            str_map[c].push_back(i);
        } else {
            vector<int> v;
            v.push_back(i);
            str_map[c] = v;
        }
    }
    
    if (is_s) {
        s_map = str_map;
    } else {
        t_map = str_map;
    }
}

void judge() {
    bool s = true;
    bool t = false;
    bool do_last_check = true;

    map_indexes_to_c(s);
    map_indexes_to_c(t);

    map_values_to_set(s);
    map_values_to_set(t);

    set<vector<int> >::iterator it;
    for (it = s_index_set.begin(); it != s_index_set.end(); it++) {
        if (t_index_set.count(*it) <= 0) {
            do_last_check = false;
            break;
        } else {
            t_index_set.erase(*it);
        }
    }

    if (do_last_check && t_index_set.empty()) {
        cout << YES << endl;
    } else {
        cout << NO << endl;
    }
}

int main() {
    cin >> S;
    cin >> T;
    s_size = S.size();
    
    judge();
}

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

int main(){
  int N;cin>>N;
  int t=1;
  for(int i=1;i<=9;i++){
    for(int k=1;k<=9;k++){
      if(i*k==N){
        t=0;
        break;
      }
    }
      if(t==0)break;
  }

  if(t==1)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

typedef tuple<ll, ll, ll> T;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;cin>>n>>m;
    int a[1000],b[1000],c[1000],dist[100][100];
    REP(i,m){
        cin>>a[i]>>b[i]>>c[i];
        a[i]--;b[i]--;
    }
    REP(i,n){
        REP(j,n){
            if(i==j) dist[i][j] = 0;
            else dist[i][j] = INF;
        }
    }
    REP(i,m){
        dist[a[i]][b[i]]=min(dist[a[i]][b[i]],c[i]);
        dist[b[i]][a[i]]=min(dist[b[i]][a[i]],c[i]);
    }
    REP(k,n){
        REP(i,n){
            REP(j,n) dist[i][j] = min(dist[i][j],dist[i][k]+dist[k][j]);
        }
    }
    int ans=m;
    REP(i,m){
        bool shortest=false;
        REP(j,n) if(dist[j][a[i]]+c[i]==dist[j][b[i]]) shortest=true;
        if(shortest) ans--;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] A = new int[N];
    for (int i = 0; i < N; i++) {
      A[i] = sc.nextInt();
    }
    float ans = 0;
    for (int i = 0; i < N; i++) {
      ans += 1 / (float) A[i];
    }
    System.out.println(1/ans);
  }
}

Measured memory_bytes: 22740
#include <stdio.h>

int main(void) {
	int N, K;
	int tomatu = 0;
	if (scanf("%d%d", &N, &K) != 2) return 1;
	do {
		tomatu++;
	} while ((N /= K) > 0);
	printf("%d\n", tomatu);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
#include <functional>
#include <list>
#include <iomanip>
#include <cctype>
#include <math.h>

#define rep(i,a,n) for(int i = a; i < (int)(n); i++)

using namespace std;


int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int k,x;
    cin >> k >> x;
    string s = " ";
    
    rep(i,x-k+1,x+k){
        cout << i;
        cout << s;
        
    }
}
    



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstdio>
#include <queue>
using namespace std;

enum { PER, ON, OFF };
const int INF = 1 << 30;
const int dc[] = {1, 0, -1, 0};
const int dr[] = {0, 1, 0, -1};

typedef struct
{
  int p[3];
} Light;

class RC
{
public:
  int r, c;
  RC(int _r = 0, int _c = 0)
    :r(_r), c(_c) {}
};

int main()
{
  int R, C, M;
  while (~scanf("%d %d %d", &R, &C, &M)) {
    vector<string> office(R);
    for (int r = 0; r < R; ++r)
      cin >> office[r];

    vector<vector<Light> > cost(R, vector<Light>(C));
    for (int i = 0; i < 3; ++i) {
      for (int r = 0; r < R; ++r) {
	for (int c = 0; c < C; ++c)
	  scanf("%d", &cost[r][c].p[i]);
      }
    }
  
    vector<RC> task(M);
    for (int i = 0; i < M; ++i)
      scanf("%d %d", &task[i].r, &task[i].c);


    vector<vector<vector<vector<int> > > > path(R, vector<vector<vector<int> > >(C, vector<vector<int> >(R, vector<int>(C, INF))));
    for (int r = 0; r < R; ++r) {
      for (int c = 0; c < C; ++c) {
	if (office[r][c] == '#')
	  continue;

	path[r][c][r][c] = 0;
	queue<RC> que;
	vector<vector<int> > visited(R, vector<int>(C, 0));
	que.push(RC(r, c));
	while (!que.empty()) {
	  RC rc = que.front();
	  que.pop();
	  visited[rc.r][rc.c] = 1;
	  for (int d = 0; d < 4; ++d) {
	    int rr = rc.r + dr[d];
	    int cc = rc.c + dc[d];
	    if (rr < 0 || rr >= R || cc < 0 || cc >= C || office[rr][cc] == '#' || visited[rr][cc])
		continue;
	    path[r][c][rr][cc] = path[r][c][rc.r][rc.c]+1;
	    que.push(RC(rr, cc));
	  }
	}
      }
    }


    int time = 0;
    vector<vector<vector<int> > > pass(R, vector<vector<int> >(C));
    for (int i = 0; i < M-1; ++i) {
      RC s = task[i], t = task[i+1];
      while (s.r != t.r || s.c != t.c) {
	pass[s.r][s.c].push_back(time++);
	for (int d = 0; d < 4; ++d) {
	  int rr = s.r + dr[d];
	  int cc = s.c + dc[d];
	  if (rr < 0 || rr >= R || cc < 0 || cc >= C)
	    continue;
	  if (path[rr][cc][t.r][t.c]+1 == path[s.r][s.c][t.r][t.c]) {
	    s.r = rr;
	    s.c = cc;
	    break;
	  }
	}
      }
    }
    // fix
    pass[task[M-1].r][task[M-1].c].push_back(time);

    int ans = 0;
    for (int r = 0; r < R; ++r) {
      for (int c = 0; c < C; ++c) {
	if (pass[r][c].empty())
	  continue;

	const int on_off = cost[r][c].p[ON] + cost[r][c].p[OFF];
	ans += on_off * pass[r][c].size();

	for (unsigned int i = 0; i < pass[r][c].size()-1; ++i) {
	  const int per = (pass[r][c][i+1] - pass[r][c][i]) * cost[r][c].p[PER];
	  if (per < on_off)
	    ans -= (on_off- per);
	}
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}

Measured memory_bytes: 32000
import itertools
import numpy as np
 
N = int(input())
info = []
for i in range(N):
    A = int(input())
    for _ in range(A):
        x,y = map(int,input().split())
        info.append((i,x-1,y))
A = np.array(list(itertools.product([0,1],repeat=N)), np.bool)
for i,x,y in info:
    bl = (~A[:,i]) | (A[:,x] == bool(y))
    A = A[bl]
    
answer = A.sum(axis = 1).max()
print(answer)

Measured memory_bytes: 18404
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;

//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _KTy, typename _Ty> istream& operator >> (istream& istr, pair<_KTy, _Ty>& m) { cin >> m.first >> m.second; return istr; }
template <typename _Ty> istream& operator >> (istream& istr, vector<_Ty>& v) { for (size_t i = 0; i < v.size(); i++) cin >> v[i]; return istr; }
ll modpow(ll n, ll p, ll m) { ll result = 1; while (p > 0) { if (p & 1) result = (result * n) % m; p >>= 1; n = (n * n) % m; } return result; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()
#define fake false



int main() {
	int H, W;
	cin >> H >> W;
	vector<string> a(H + 2, string(W + 2, '#'));
	for (int i = 1; i <= H; i++) {
		string tmp;
		cin >> tmp;
		for (int j = 1; j <= W; j++) {
			a[i][j] = tmp[j - 1];
		}
	}
	for (int i = 0; i < a.size(); i++) {
		cout << a[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (a,b) = readIntList()

    println(a*b)
}

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)
fun <T> Array<Array<T>>.print() {
    this.forEach {
        println(it.joinToString(" "))
    }
}

Measured memory_bytes: 36456
#include<stdio.h>

int Sort(int A[],int N){
	int i,j,t,sw=0,mini;
	for(i=0;i<N;i++){
		mini=i;
		for(j=i;j<N;j++){
			if(A[j]<A[mini])mini=j;
		}
		t=A[i];A[i]=A[mini];A[mini]=t;
		if(i!=mini)sw++;
	}
	return sw;
}

int main(){
	int A[100],N,i,sw;
	
	scanf("%d",&N);
	for(i=0;i<N;i++)scanf("%d",&A[i]);
	
	sw=Sort(A,N);
	
	for(i=0;i<N;i++){
		if(i>0)printf(" ");
		printf("%d",A[i]);
	}
	printf("\n");
	printf("%d\n",sw);
	
	return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N,M,Q;
int A[111111],B[111111],V[111111];

int L[111111],R[111111],J[111111];

const int SEG=1<<19;
int sum[SEG*2],put[SEG*2],len[SEG*2];

void init(vint &xs){
    memset(sum,0,sizeof(sum));
    memset(put,0,sizeof(put));
    memset(len,0,sizeof(len));

    for(int i=0;i+1<xs.size();i++){
        len[i+SEG-1]=xs[i+1]-xs[i];
    }

    for(int i=SEG-2;i>=0;i--){
        len[i]=len[i*2+1]+len[i*2+2];
    }
}

inline void push(int k){
    sum[k]+=put[k]*len[k];
    if(k<SEG-1){
        put[k*2+1]+=put[k];
        put[k*2+2]+=put[k];
    }
    put[k]=0;
}

void add(int a,int b,int k=0,int l=0,int r=SEG){
    push(k);
    if(r<=a||b<=l)return;
    if(a<=l&&r<=b){
        put[k]++;
        push(k);
        return;
    }
    add(a,b,k*2+1,l,(l+r)/2);
    add(a,b,k*2+2,(l+r)/2,r);
    sum[k]=sum[k*2+1]+sum[k*2+2];
}

int query(int a,int b,int k=0,int l=0,int r=SEG){
    push(k);
    if(r<=a||b<=l)return 0;
    if(a<=l&&r<=b)return sum[k];
    return query(a,b,k*2+1,l,(l+r)/2)+query(a,b,k*2+2,(l+r)/2,r);
}


signed main(){
    scanf("%lld%lld%lld",&N,&M,&Q);

    vector<tuple<int,int,int>>ops;
    rep(i,M){
        int a,b,v;
        scanf("%lld%lld%lld",&a,&b,&v);
        a--;
        ops.pb(make_tuple(v,a,b));
    }
    sort(all(ops));
    rep(i,M)tie(V[i],A[i],B[i])=ops[i];


    rep(i,Q)scanf("%lld%lld%lld",&L[i],&R[i],&J[i]),L[i]--;

    vector<int>xs;
    xs.pb(0);xs.pb(N);
    rep(i,M){
        xs.pb(A[i]);
        xs.pb(B[i]);
    }
    rep(i,Q){
        xs.pb(L[i]);
        xs.pb(R[i]);
    }
    sort(all(xs));xs.erase(unique(all(xs)),xs.end());
    rep(i,M){
        A[i]=lower_bound(all(xs),A[i])-xs.begin();
        B[i]=lower_bound(all(xs),B[i])-xs.begin();
    }

    rep(i,Q){
        L[i]=lower_bound(all(xs),L[i])-xs.begin();
        R[i]=lower_bound(all(xs),R[i])-xs.begin();
    }

    vint lb(Q),ub(Q,M);

    while(true){
        vpint qs;
        rep(i,Q){
            if(lb[i]+1==ub[i])continue;
            int mid=(ub[i]+lb[i])/2;
            qs.pb({mid,i});
        }
        if(qs.size()==0)break;
        sort(all(qs));
        int cur=0;

        init(xs);
        for(int i=0;i<M;i++){
            while(cur<qs.size()&&qs[cur].fi<=i){
                int m,k;
                tie(m,k)=qs[cur++];
                if(query(L[k],R[k])>=J[k])ub[k]=m;
                else lb[k]=m;
            }
            add(A[i],B[i]);
        }
    }

    rep(i,Q){
        printf("%lld\n",V[lb[i]]);
    }
    return 0;
}

Measured memory_bytes: 42860
'use strict'

const main = (input) => {
    const al = 'abcdefghijklmnopqrstuvwxyz'
    const S = input.split('\n')[0]
    const alArr = al.split('')
    const SArr = [...new Set(S.split('').sort())]
    for(let i = 0; i <= alArr.length; i++){
        if(alArr[i] !== SArr[i]){
            console.log(alArr[i])
            return
        }
    }
    console.log('None')
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

Measured memory_bytes: 15640
#include <stdio.h>

int main(void) {
    long long H, x, i;
    scanf("%lld", &H);
    i=0;
    while (H!=0) {
        H/=2;
        i++;
    }
    x=1;
    while (i!=0) {
        x*=2;
        i--;
    }
    x--;
    printf("%lld", x);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

long long int INF = 1e18;
long long int mod = 1000000007;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(15)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll abc,ll bed){
    //abcのbed乗を計算する
    if(bed==0){return 1;}
    else{
        ll ced = rui(abc,bed/2);
        ced *= ced;
        ced %= mod;
        if(bed%2==1){ced*=abc; ced%=mod;}
        return ced;
    }
}
ll gcd(ll number1,ll number2){
	if(number1 > number2){
		swap(number1,number2);
	}
	if(number1 == 0 || number1 == number2){
		return number2;
	}else{
		return gcd(number2 % number1,number1);
	}
}

ll i,j,k,ii,jj,r,l;
ll n,m,num,sum,ans;
ll a,b,c,d,e,g,h,w;
ll x[500005],y[500005],z[500005];
ll dp[2005][2005];
ll migi[2005][2005];
ll sita[2005][2005];
char s[2005][2005];

int main(){
	cin >> h >> w >> k;
	for(i=1;i<=h;i++){
		cin >> s[i];
	}
	for(i=1;i<=h;i++){
		for(j=1;j<=w;j++){
			if(s[i][j-1] == '1')dp[i][j] = 1;
		}
	}

	for(i=1;i<=h;i++){
		for(j=1;j<=w-1;j++){
			if(dp[i][j] == 1 && dp[i][j+1] == 1){
				migi[i][j] = 1;
			}
		}
	}
	for(i=1;i<=h-1;i++){
		for(j=1;j<=w;j++){
			if(dp[i][j] == 1 && dp[i+1][j] == 1){
				sita[i][j] = 1;
			}
		}
	}
	for(i=1;i<=h;i++){
		for(j=1;j<=w;j++){
			dp[i][j] += dp[i-1][j];
			migi[i][j] += migi[i-1][j];
			sita[i][j] += sita[i-1][j];
		}
	}
	for(i=1;i<=h;i++){
		for(j=1;j<=w;j++){
			dp[i][j] += dp[i][j-1];
			migi[i][j] += migi[i][j-1];
			sita[i][j] += sita[i][j-1];
		}
	}
	for(i=1;i<=h;i++){
		for(j=1;j<=w;j++){
			//pe(sita[i][j]);
		}
		//el;
	}
	for(i=0;i<k;i++){
		ll bx,by,ax,ay;
		cin >> bx >> by >> ax >> ay;
		num = dp[ax][ay] - dp[bx-1][ay] - dp[ax][by-1] + dp[bx-1][by-1];
		//pe(num);
		if(by != ay)num -= migi[ax][ay-1] - migi[bx-1][ay-1] - migi[ax][by-1] + migi[bx-1][by-1];
		if(bx != ax)num -= sita[ax-1][ay] - sita[bx-1][ay] - sita[ax-1][by-1] + sita[bx-1][by-1];
		p(num);
	}
	return 0;
}

Measured memory_bytes: 124800
from collections import Counter
def main():
    n = int(input())
    a = list(map(int, input().split()))
    a1 = [i + 1 for i in a]
    a2 = [i - 1 for i in a]
    a = a + a1 + a2
    ac = Counter(a)    
    print(ac.most_common()[0][1])

if __name__ == '__main__':
    main()


Measured memory_bytes: 32172
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n);
  for (int i=0; i<n; i++) {
    cin >> a[i];
    cin >> b[i];
    cin >> c[i];
  }
  int dp[n+1][3]; // i-1日目にjを選んだ時のdp[i][j]はi日目までの幸福度の総和の最大値
  dp[0][0] = 0;
  dp[0][1] = 0;
  dp[0][2] = 0;
  for (int i=0; i<n; i++) {
     dp[i+1][0] = max(dp[i][1]+b[i], dp[i][2]+c[i]);
     dp[i+1][1] = max(dp[i][2]+c[i], dp[i][0]+a[i]);
     dp[i+1][2] = max(dp[i][0]+a[i], dp[i][1]+b[i]);
     //      cout << dp[i+1][0] << " " << dp[i+1][1] << " " << dp[i+1][2] << endl;      
  }
  cout << max(max(dp[n][0], dp[n][1]), dp[n][2]) << endl;
  return 0;
}


Measured memory_bytes: 2560
#include <iostream>                                                    
#include <vector>                                                      
#include <algorithm>                                                   
using namespace std;                                                   
                                                                       
int main() {                                                           
  int n;                                                               
  cin >> n;                                                            
  vector<int> S(n);                                                    
  for (int i=0; i<n; i++) {                                            
    cin >> S[i];                                                       
  }                                                                    
  sort(S.begin(), S.end());                                            
                                                                       
  int q;                                                               
  cin >> q;                                                            
  vector<int> T(q);                                                    
  for (int i=0; i<q; i++) {                                            
    cin >> T[i];                                                       
  }                                                                    
                                                                       
  int ans = 0;                                                         
  for (int i=0; i<q; i++) {                                            
    if (binary_search(S.begin(), S.end(), T[i])) {                     
      ans++;                                                           
    }                                                                  
  }                                                                    
  cout << ans << endl;                                                 
  return 0;                                                            
}                                                                      
                                                                       
                                                                       
                                                                       
        

Measured memory_bytes: 3360
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL =long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 9; //924844033 1000000000 + 7;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, p, q, last, first, cnt, sum, ans,dp[800][10][2], a[200000], b[200000];
string str, ss;
bool f;
char c[800][800];
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
struct Edge { LL to, cost; };
struct edge { LL from, to, cost; };
vector<Edge>vec[20000];
vector<edge>ed;
vector<LL>v;
map<string,LL>ma;
set<LL>st;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
int main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
	}
	rep(i, n) {
		cin >> b[i];
		a[i] = a[i]-b[i];
		sum += a[i];
	}
	if (sum < 0) {
		cout << -1 << endl;
		return 0;
	}
	sort(a, a + n);
	last = n - 1;
	rep(i,n) {
		if (a[i] >= 0)break;
		while (a[i] < 0) {
			if (a[last] > -a[i]) {
				a[last] += a[i], a[i] = 0;
				f = 1;
			}
			 else if(a[last]<-a[i]){
				a[i] += a[last], last--;
				f = 0;
			}
			 else {
				 a[i] = 0, a[last] = 0;
				 last--;
				 f = 0;
			 }
		}
			cnt++;
	}
	cout << min(n,cnt + n - last + f-1) << endl;
	return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

map<ll, ll> primeFactors(ll n)
{
    map<ll, ll> ret;
    while (n % 2 == 0)
    {
        if( ret.find(2) != ret.end() ) {
            ret[2]++;
        }
        else
        {
            ret[2] = 1;
        }
        n = n / 2;
    }
    for (ll i = 3; i <= sqrt(n); i = i+2)
    {
        while (n%i == 0)
        {
            if( ret.find(i) != ret.end() ) {
            ret[i]++;
        }
        else
        {
            ret[i] = 1;
        }
            n = n / i;
        }
    }
    if (n > 2)
        {
            if( ret.find(n) != ret.end() ) {
            ret[n]++;
        }
        else
        {
            ret[n] = 1;
        }
        }
    return ret;
}

void print_map(map<ll, ll> mp){
    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
        std::cout << "key = " << itr->first           // キーを表示
                        << ", val = " << itr->second << "\n";    // 値を表示
    }
}

int main()
{
    ll N, L;
    cin >> N >> L;
    vector<string> str(N);
    rep(i, N)
    {
        cin >> str.at(i);
    }
    sort(str.begin(), str.end());
    rep(i, N){
        cout << str.at(i);
    }
    cout << endl;
    return 0;
}


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

a.sort(reverse=True)
c = 0
v = []
for i in range(n-1):
    if a[i] != a[i+1]:
        c += 1
        if c >= 2:
            v.append([a[i],c])
        c = 0
    else:
        c += 1
if a.count(a[-1]) >=2 :
    v.append([a[-1],a.count(a[-1])])
if len(v) == 0:
    print(0)
elif v[0][1] >= 4:
    print(v[0][0]**2)
elif len(v) >= 2:
    print(v[0][0]*v[1][0])
else:
    print(0)

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

int main(){
    int N;
    int input[200];

    cin >> N;
    for (int i = 0; i < N; i ++){
        cin >> input[i];
    }
    int c = 0;
    int exist_odd = 0;
    while(true){
        for (int i = 0; i < N; i ++){
            if (input[i] % 2 != 0){
                //cout << i << endl;
                exist_odd = 1;
            }
        }
        if (exist_odd == 1){
            break;
        }
        for (int i = 0; i < N; i++){
            input[i] /= 2;
        }
        c++;
        
    }

    cout << c << endl;

}

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

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> istream& operator>>(istream &is, pair<S, T> &p){ return is >> p.first >> p.second; }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ return os << "[" << p.first << ", " << p.second << "]"; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define For1(i, n) for(int i = 1; i <= (n); i ++)
#define Rof(i, n) for(int i = (n)-1; i >= 0; i --)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)
#define Return(x) { Cout(x); return 0; }

// constexpr int MOD = 1e9+7;
#include <queue>

int main(void){
    Cin(int, n, nc);
    vc<pair<pair<int, int>, int>> pr(n);
    For(i, n){
        cin >> pr[i].first.first >> pr[i].first.second >> pr[i].second;
        pr[i].second --;
    }
    Sort(pr);

    vc<vc<pair<int, int>>> pt(nc);
    For(i, n){
        int s = pr[i].first.first, t = pr[i].first.second, c = pr[i].second;
        if(pt[c].empty() || pt[c].back().second < s){
            pt[c].emplace_back(s, t);
        }
        else{
            pt[c].back().second = t;
        }
    }
    
    vc<pair<int, int>> p; p.reserve(n);
    For(i, nc) copy(Range(pt[i]), back_inserter(p));
    Sort(p);
    
    priority_queue<int, vector<int>, greater<int>> q;
    q.push(0);
    for(auto &e : p){
        int s = e.first, t = e.second;
        if(s > q.top()) q.pop();
        q.push(t);
    }
    Cout(q.size());
}


Measured memory_bytes: 3456
#include <stdio.h>

int main(void)
{

    int a, b, c, d;

    scanf("%d %d %d", &a, &b, &c);

    d = c + b - a;

    if (d <= 0)
    {
        d = 0;
    }
    printf("%d\n", d);
    return 0;
}

Measured memory_bytes: 128