akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int main() {
	int n;
	cin >> n;
	vector<long long int >s;
	for (int i = 0; i < n; i++) {
		long long int a;
		cin >> a;
		s.push_back(a);
	}
	long long int two = 0;
	long long int four = 0;
	long long int zero = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] % 4 == 0) {
			four++;
		}
		else if (s[i] % 2 == 0) {
			two++;
		}
		else {
			zero++;
		}
	}
	if (four + zero == n) {
		if (four >= n / 2) {
			cout << "Yes";
		}
		else {
			cout << "No";
		}
	}
	else {
		if (four >= zero) {
			cout << "Yes";
		}
		else {
			cout << "No";
		}
	}
}


Measured memory_bytes: 1400
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney,chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun


#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")

int ctoi(char c) {
	switch (c)
	{
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default:
		cout << "ERR_ctoi" << endl;
		return -1;
	}
}
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	PRI(a * b / 2);
	return 0;
}

Measured memory_bytes: 3564
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
#include <map>
#include <set>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using PP = pair<P, string>;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    int dx = tx - sx;
    int dy = ty - sy;

    for (int i = 0; i < dy; i++)
        cout << 'U';
    for (int i = 0; i < dx; i++)
        cout << 'R';

    for (int i = 0; i < dy; i++)
        cout << 'D';
    for (int i = 0; i < dx; i++)
        cout << 'L';

    cout << 'L';
    for (int i = 0; i < dy; i++)
        cout << 'U';
    cout << 'U';
    for (int i = 0; i < dx; i++)
        cout << 'R';
    cout << 'R';
    cout << 'D';
    cout << 'R';
    for (int i = 0; i < dy; i++)
        cout << 'D';
    cout << 'D';
    for (int i = 0; i < dx; i++)
        cout << 'L';
    cout << 'L';
    cout << 'U';
    cout << endl;
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, b) for (int i = a; i <= b; ++i)
#define PER(i, a, b) for (int i = a; i >= b; --i)
#define RVC(i, S) for (int i = 0; i < S.size(); ++i)
#define mp make_pair
#define pb push_back
#define debug(...) fprintf(stderr, __VA_ARGS__)
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> pii;

inline int read(){
	int x = 0, ch = getchar(), f = 1;
	while (!isdigit(ch)){if (ch == '-') f = -1; ch = getchar();}
	while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
	return x * f;
}

int n;
LL a[100005], cnt[100005];
int main(){
	n = read();
	LL sum = 0;
	REP(i, 1, n){
		a[i] = read();
		sum += a[i];
	}
	LL t = 1ll * n * (n + 1) / 2;
	if (sum % t != 0) return printf("NO\n"), 0;
	LL w = sum / (1ll * n * (n + 1) / 2);
	LL tot = 0;
	REP(i, 1, n){
		LL x = a[i];
		LL y;
		if (i < n) y = a[i + 1];
		else y = a[1];
		LL a = x - y + w;
		if (a < 0) return printf("NO\n"), 0;
		if (a % n == 0) cnt[i] = a / n, tot += cnt[i];
		else return printf("NO\n"), 0;
	}
	if (tot != w) printf("NO\n");
	else printf("YES\n");
	return 0;
}

Measured memory_bytes: 1792
N, M = map(int, input().split())
E = []
for _ in range(M):
    a,b,c = map(int, input().split())
    E.append((a,b,c))
dist = [-N*10**9]*(N+1)
dist[1] = 0
flag = False
for i in range(N):
    for (a,b,c) in E:
        newlen = dist[a] + c
        if newlen > dist[b]:
            if i == N-1:
                flag = True
            dist[b] = newlen
            predist = dist[N]

dist2 = dist.copy()
for i in range(N):
    for (a,b,c) in E:
        newlen = dist2[a] + c
        if newlen > dist2[b]:
            dist2[b] = newlen
if dist2[N] > dist[N]:
    print("inf")
else:
    print(dist[N])

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

int main() {
  int A, B;
  int x,y;
  cin >> A >> B;
  
  x = A % 500 ;
  if ( x <= B ) {
    cout << "Yes" ;
  }
  else {
    cout << "No" ;
  }

}

Measured memory_bytes: 256
h,n= map(int, input().split())
p = [list(map(int, input().split())) for _ in range(n)] 
m = 10**4
dp = [0]*(h+m+1)
for i in range(m+1,h+m+1):
  dp[i] = min(dp[i-a] + b for a,b in p)
print(dp[h+m])

Measured memory_bytes: 9592
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
const int N = 200005;
typedef long long lld;
lld n;
lld a[N];
lld st[N], top = 0;
lld lef[N], rig[N];
lld ans = 0;
int main() {
//	freopen("data.in", "r", stdin);
	scanf("%lld", &n);
	for(lld i = 1; i <= n; i++) 
		scanf("%lld", &a[i]);
	for(lld i = 1; i <= n; i++) {
		if(a[i] > st[top]) {
			st[++top] = a[i]; 
			continue;
		}
		while(a[i] < st[top]) {
			rig[st[top]] = i;
			top--;
		}
		st[++top] = a[i];
	}
	while(top > 0){
		rig[st[top]] = n + 1;
		top--;
	}
	top = 0;
	for(lld i = n; i >= 1; i--) {
		if(a[i] > st[top]) {
			st[++top] = a[i];
			continue;
		}
		while(a[i] < st[top]) {
			lef[st[top]] = i;
			top--;
		}
		st[++top] = a[i];
	}
	while(top > 0) {
		lef[st[top]] = 0;
		top--;
	}
	for(lld i = 1; i <= n ;i++) {
		lld left = i - lef[a[i]];
		lld right = rig[a[i]] - i;
		lld tmp = 1ll * right * left;
		ans += 1ll * tmp * a[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6528
#https://atcoder.jp/contests/abc098/tasks/arc098_a

n = int(input())
d = input()

pre = d[1:].count('E')
minimum = pre
for i in range(1,n):
    if d[i-1]=='W':
        pre = pre+1
    if d[i]=='E':
        pre = pre-1
    minimum = min(pre, minimum)

print(minimum)


Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
int a,b;
bool flag=true;
int main() {
    string A;
    cin>>a>>b>>A;
    
    for(int i=0;i<a;i++)
    {
        if(A[i]>'9'||A[i]<'0')
        {
            flag=false;
        }
    }
    if(A[a]!='-')
    {
        flag=false;
    }
    for(int i=a+1;i<a+1+b;i++)
    {
        if(A[i]>'9'||A[i]<'0')
        {
            flag=false;
        }
    }
    if(flag==false)
    {
        printf("No");

    }
    else
    {
        printf("Yes");
    }
}
    
    
    
       

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int ll
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

signed main() {
    int n;
    cin >> n;
    int a[n];
    int sum = 0;
    rep (i, 0, n) {
        cin >> a[i];
        sum += a[i];
    }
    int ans = inf;
    int arai = 0;
    rep (i, 0, n - 1) {
        arai += a[i];
        ans = min (ans, abs (sum - 2 * arai));
    }
    cout << ans << "\n";
}

Measured memory_bytes: 5184
n=int(input())
d=sorted(map(int,input().split()))
m=int(input())
t=sorted(map(int,input().split()))

d_dic = dict()
t_dic = dict()

for i in range(n):
    d1 = d[i]
    if d1 not in d_dic.keys():
        d_dic[d1] = 1
    else:
        d_dic[d1] += 1

ans = 0

for i in range(m):
    t1 = t[i]
    if t1 in d_dic.keys():
        d_dic[t1] -= 1
        if d_dic[t1] < 0:
            ans = 1
            break
    else:
        ans = 1
        break
    
if ans == 1:
    print("NO")
else:
    print("YES")

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

const int MOD = (int)1e9+7;

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

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> A(N);
  int ma=0;
  for(int i=0;i<N;i++){
    cin >> A.at(i);
    ma=max(ma,A.at(i));
  }

  int ans=A.at(0);
  for(int i=0;i<N;i++){
    ans=gcd(ans,A.at(i));
  }
  if(K<=ma && K%ans==0)  cout << "POSSIBLE" << endl;
  else  cout << "IMPOSSIBLE" << endl;

  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n;
int bit[100010];
void init(int n_){
  n=n_;
  for(int i=0;i<=n;i++){
    bit[i]=0;
  }
}
void update(int a,int w){
  for(int x=a;x<=n;x+=x&-x){
    bit[x]+=w;
  }
}
int query(int a){
  int s=0;
  for(int x=a;x>0;x-=x&-x){
    s+=bit[x];
  }
  return s;
}
int main(){
  int n,q,i;
  cin >> n >> q;
  init(n);
  int a,b,c;
  for(i=0;i<q;i++){
    cin >> a >> b >> c;
    if(a==0){
      update(b,c);
    }
    else{
      cout << query(c)-query(b-1) << endl;
    }
  }
}


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

#define ll long long
#define mod 1000000007
#define pll pair<long long,long long>
#define pdd pair<long double,long double>
#define vll vector<ll>
#define rep(i,j,n) for(int i=j;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
priority_queue<pll,vector<pll>,greater<pll> >pq;
priority_queue<ll,vector<ll>,greater<ll> >pq1;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a,b,c;
    cin>>a>>b>>c;
 	if(a+b+c>=22)
      cout<<"bust";
  	else
      cout<<"win";

    return 0;
}


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

using namespace std;
#define ff(i,n,m) for(int i=n;i<m;i++)

int main()
{
	string a;
	cin >> a;
	deque<char> ans;
	ff(i, 0, a.size()) {
		if (a[i] == 'B') {
			if (ans.size() > 0) {
				ans.pop_back();
			}
		}
		else {
			ans.push_back(a[i]);
		}
	}
	while (!ans.empty()) {
		cout << ans.front();
		ans.pop_front();
	}

	return 0;
}

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

using namespace std;

void execute()
{
	int a, b;
	int mul = 1;
	bool ans;

	cin >> a >> b;

	mul = b > 10 ? (b == 100 ? 1000 : 100) : 10;

	a = a * mul + b;

	for (int i = 1; i <= a; i++)
	{
		if (a == i * i)
		{
			cout << "Yes" << endl;
			return;
		}
	}

	cout << "No" << endl;
	return;
}

int main()
{
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin>>n;
    for(ll i=1;i<=n;i++){
        ll ri=sqrt(i);
        ll ans=0;
        for(ll x=1;x<ri;x++){
            for(ll y=x;y<ri;y++){
                for(ll z=y;z<ri;z++){
                    if(x*x+y*y+z*z+x*y+y*z+z*x==i){
                        if(x!=y&&y!=z) ans+=6;
                        else if(x==y&&y==z) ans+=1;
                        else ans+=3;
                    }
                }
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}

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

int main(){
    string s;
    cin >> s;
    int dif1 = 0, dif2 = 0;
    for(int i=0; i<s.size(); i++){
        if(i%2==0){
            if(s[i]=='0'){
                dif1++;
            }
        }else{
            if(s[i]=='1'){
                dif1++;
            }
        }
    }
    for(int i=0; i<s.size(); i++){
        if(i%2==0){
            if(s[i]=='1'){
                dif2++;
            }
        }else{
            if(s[i]=='0'){
                dif2++;
            }
        }
    }
    cout << min(dif1, dif2) << endl;
    return 0;
}

Measured memory_bytes: 512
x, y = map(int, input().split())
a = (- x + 2 * y) // 3
b = (2 * x - y) // 3
p = 1000000007
if (x + y) % 3 != 0 or a < 0 or b < 0:
    print(0)
else:
    fact = [1] * 700000
    for i in range(2, a + b + 1):
        fact[i] = fact[i - 1] * i % p

    def pow(a, n):
        if n == 0:
            return 1
        elif n == 1:
            return a
        elif n % 2 == 0:
            return pow(a, n // 2) ** 2 % p
        else:
            return a * pow(a, n // 2) ** 2 % p

    print(fact[a + b] * pow(fact[a], p - 2) * pow(fact[b], p - 2) % p)



Measured memory_bytes: 29684
#include<stdio.h>

long long inp_n, i1;

double out_n;

long long readNumber() {
	long long temp_func;
	scanf("%lld", &temp_func);
	return temp_func;
};
long long printNumber(long long temp_func) {
	printf("%lld", temp_func);
	return 0;
};

int main() {
	
	inp_n = readNumber();
	
	out_n = inp_n * 6.28318530717958623200;
	
	printf("%0.5f", out_n);
	
	return 0;
	
}

Measured memory_bytes: 1748
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int in(){int x; scanf("%d",&x); return x;}
static const int MAX = 100;


int main(){
  int N = in(), A[MAX];
  rep(i, N) cin >> A[i];
  sort(A, A+N);

  int count = 0;
  rep(i, N-1){
    if(A[i] < A[i+1]) count++;
  }
  cout << count+1 << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  vector<int> a(3);
  for (int i = 0; i < 3; ++i) {
    scanf("%d", &a[i]);
  }
  int k;
  scanf("%d", &k);
  sort(a.begin(), a.end());
  int ret = a[0] + a[1] + (a[2] << k);
  printf("%d\n", ret);
  return 0;
}


Measured memory_bytes: 256
def main():


   X = int(input())
   oriList = list(map(int,input().split()))
   lis = sorted(list(oriList))

   if len(lis)%2==0:
      mid = lis[len(lis)//2-1]
      nextmid = lis[len(lis)//2]
   else:
      mid = lis[(len(lis)+1)//2-1]
      nextmid = lis[(len(lis)+1)//2]
   


   for i in oriList:
      if i <= mid:
         print(nextmid)
      else:
         print(mid)


   





if __name__== "__main__":
    main() 






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

int main() {
  int n, k, r, s, p;
  cin>>n>>k>>r>>s>>p;
  string t;
  cin>>t;

  long long ans = 0;
  for (int i=0; i<k; i++) {
    long long dp[3];
    if (t[i] == 'r') {
      dp[0] = 0;
      dp[1] = 0;
      dp[2] = p;
    } else if (t[i] == 's') {
      dp[0] = r;
      dp[1] = 0;
      dp[2] = 0;
    } else {
      dp[0] = 0;
      dp[1] = s;
      dp[2] = 0;
    }
    for (int j=i+k; j<n; j+=k) {
      long long prev_dp0 = dp[0];
      long long prev_dp1 = dp[1];
      long long prev_dp2 = dp[2];
      if (t[j] == 'r') {
        dp[0] = max(prev_dp1, prev_dp2);
        dp[1] = max(prev_dp0, prev_dp2);
        dp[2] = max(prev_dp0 + p, prev_dp1 + p);
      } else if (t[j] == 's') {
        dp[0] = max(prev_dp1 + r, prev_dp2 + r);
        dp[1] = max(prev_dp0, prev_dp2);
        dp[2] = max(prev_dp0, prev_dp1);
      } else {
        dp[0] = max(prev_dp1, prev_dp2);
        dp[1] = max(prev_dp0 + s, prev_dp2 + s);
        dp[2] = max(prev_dp0, prev_dp1);
      }
    }
    ans += max(dp[0], max(dp[1], dp[2]));
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 512
N = int(input())
A = list(map(int, input().split()))
if N == 0 and A[0] == 1:
  print(1)
  quit()

if A[-1] == 0:
  print(-1)
  quit()

if A[0] != 0:
  print(-1)
  quit()

n = [0] * (N+1)
n[0] = 1
for i in range(1, N+1):
  a = A[i]
  m = n[i-1] * 2
  n[i] = m - a
  if n[i] < 0:
    print(-1)
    quit()

n[-1] = 0
for i in range(N-1, 0, -1):
  nn = n[i+1]
  a = A[i+1]
  n[i] = min(n[i], a + nn)

print(sum(n) + sum(A))

Measured memory_bytes: 673508
# coding: utf-8
# Your code here!

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

A.sort()

# print(A)

# print(abs(A[1] - A[0]))
# print(abs(A[2] - A[1]))

print((0) + (abs(A[1] - A[0])) + (abs(A[2] - A[1])))

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

int main()
{
    int N;
    ll H;
    cin >> N >> H;
    int b[N+3];
    ll am = 0;
    for(int i = 0; i < N; ++i) {
        ll a;
        scanf("%lld %d", &a, &b[i]);
        am = max(am, a);
    }

    sort(b, b + N, [](int &x, int &y){ return x > y;});
    
    ll cnt = 0;
    for(cnt = 0; cnt < (ll)N; ++cnt) {
        if(H <= 0) { cout << cnt << endl; return 0; }
        if(b[cnt] < am) break;
        H -= b[cnt];
    }
    if(H >= 0)  cnt += (H % am != 0) ? H/am + 1 : H/am; 
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 640
def drop(a,x,y)
  a[y][x] += 1 if x >= 0 and x < 10 and y >= 0 and y < 10
end

a = Array.new(10){Array.new(10, 0)}
while gets
  x,y,m = $_.split(",").map(&:to_i)
  case m
  when 1
    drop(a,x,y-1)
    drop(a,x-1,y);drop(a,x,y);drop(a,x+1,y)
    drop(a,x,y+1)
  when 2
    drop(a,x-1,y-1);drop(a,x,y-1);drop(a,x+1,y-1)
    drop(a,x-1,y);drop(a,x,y);drop(a,x+1,y)
    drop(a,x-1,y+1);drop(a,x,y+1);drop(a,x+1,y+1)
  when 3
    drop(a,x,y-2)
    drop(a,x-1,y-1);drop(a,x,y-1);drop(a,x+1,y-1)
    drop(a,x-2,y);drop(a,x-1,y);drop(a,x,y);drop(a,x+1,y);drop(a,x+2,y);
    drop(a,x-1,y+1);drop(a,x,y+1);drop(a,x+1,y+1)
    drop(a,x,y+2)
  end
end
puts "#{a.flatten.count(0)}\n#{a.flatten.max}"

Measured memory_bytes: 8672
n, m, l=(int(x) for x in input().split())
A=[[int(x) for x in input().split()] for i in range(n)]
B=[[int(x) for x in input().split()] for i in range(m)]
C=[[0]*l for i in range(n)]
for i in range(n):
    for j in range(l):
        sum=0
        for k in range(m):
            sum+=A[i][k]*B[k][j]
        C[i][j]=sum
for i in range(n):
    for j in range(l):
        if j!=l-1:
            print(C[i][j], end=" ")
        else:
            print(C[i][j])


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

int main(){
    int n;
    cin >> n;
    vector<int> v(n+1);
    for(int i=0; i<n; i++) cin >> v[i];

    int cnt = 0;
    while(true){
        bool flag = true;
        for(int i=0; i<n; i++) if(v[i] != 0) flag = false;
        if(flag) break;

        int l = 0;
        for(int i=0; i<n; i++){
            if(v[i] != 0){
                l = i;
                break;
            }
        }

        int r = l;
        while(r < n && v[r+1] != 0) r++;

        for(int i=l; i<=r; i++) v[i]--;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    static long[] pnumInL;
    static long[] lenL;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long x = sc.nextLong();
        sc.close();

        pnumInL = new long[n+1];
        lenL = new long[n+1];
        pnumInL[0] = 1;
        lenL[0] = 1;
        for(int i=0; i<n; i++){
            pnumInL[i+1] = pnumInL[i] * 2 + 1;
            lenL[i+1] = lenL[i] * 2 + 3;
        }

        System.out.println(culcPnum(n, 1, x));
    }

    public static long culcPnum(int level, long start, long end){
        long mlen = end - start + 1;
        if(level == 0 && mlen == 1) return 1;
        if(mlen <= 1) return 0;
        if(mlen >= lenL[level]-1) return pnumInL[level];
        if(mlen >= lenL[level-1] + 2){
            return pnumInL[level-1] + 1 + culcPnum(level-1, start + lenL[level-1]+2, end);
        }else{
            return culcPnum(level-1, start+1, end);
        }
    }
}

Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

// 反転した文字列が等しいなら回文
bool is_palindrome(string s){
    // basic_string::rbegin, rend ... 逆イテレータ(末尾と先頭)
    // endは末尾のひとつ先
    string t(s.rbegin(),s.rend()); // sの反転で初期化
    return s == t;
}

int main(){
    string s;
    cin >> s;
    int n = s.size();
    /*
    // 逆イテレータの動作確認
    for (auto itr = s.rbegin(); itr < s.rend(); itr++)
    {
        cout << *itr;
    }
    cout << endl;
    */

    // substr(pos, n = npos)
    // s[pos]からs[pos+n]までの部分文字列を返す
    // nを省略すると，posからsの末尾まで
    if (is_palindrome(s) &&
        is_palindrome(s.substr(0, (n-1)/2)) && 
        is_palindrome(s.substr((n+1)/2)   )
        ) { 
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline


n = int(input())
a = list(map(int,input().split()))

judge = False

for e in a:
    if e == 0:
        judge = True
if judge:
    print(0)
    exit()

res = 1
for e in a:
    res = res*e
    if res > 10**18:
        res = -1
        break


if res == -1:
    print(-1)
else:
    print(res)

Measured memory_bytes: 85308
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()

	ans := 1001001001001
	for i := 1; i*i <= N; i++ {
		if N%i == 0 {
			c := i + N/i - 2
			ans = min(c, ans)
		}
	}
	out(ans)
}


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

using namespace std;

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> a(n + 2);
    ll len = 0;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        len += abs(a[i] - a[i - 1]);
    }
    len += abs(a[n]);
    for (int i = 1; i <= n; ++i) {
        cout << len - abs(a[i] - a[i - 1]) - abs(a[i + 1] - a[i]) + abs(a[i + 1] - a[i - 1]) << '\n';
    }
    return 0;
}

Measured memory_bytes: 1664
X,Y=map(int,input().split())
import math

def combination(n, r, mod=10**9+7):
    n1, r = n+1, min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod-2, mod) % mod

def f2(r):

    return inv_t
def co(n,r):
    P = 10**9 + 7
    N = r+1
    inv_t = [0]+[1]
    for i in range(2,N+1):
        inv_t += [inv_t[P % i] * (P - int(P / i)) % P]
    ans =1
    for i in range(1,r+1):
        ans = (ans * (n+i-1)) % P
    for i in range(1,r+1):
        ans = (ans * inv_t[i]) % P
    return ans
if (X+Y)%3==0:
    Z=X+Y
    if min(X,Y)-Z//3 >-1:
        #print(1)
        print(combination(Z//3,min(X,Y)-Z//3))
        #print(co(Z//3,min(X,Y)-Z//3))
    else:
        print(0)
else:
    print(0)

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <ios>
#include <iostream>
#include <vector>

#define ll long long

using namespace std;

int N, K;
size_t D;
vector<bool> fav(10, true);
int digit = 1;
int v;

int dfs(int value, int digit)
{
    if (digit == 0) {
        if (value >= N) {
            return value;
        } else {
            // cout << value << endl;
            return -1;
        }
    }

    for (int i = 0; i <= 9; i++) {
        if (fav[i]) {
            int d = dfs(value + i * digit, digit / 10);
            if (d > 0) {
                return d;
            }
        }
    }

    return -1;
}

int main()
{
    cin >> N >> K;
    for (int i = 0; i < K; i++) {
        cin >> D;
        fav[D] = false;
    }

    while (N / digit > 10) {
        digit *= 10;
    }

    do {
        // cout << "digit : " << digit << endl;
        v = dfs(0, digit);
        digit *= 10;
    } while (v < 0);

    cout << v << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        for(int i = 0; i < s.length(); i++){
            int x = s.charAt(i) + n;
        	if(x > 90){
            	x -= 26;
            }
            System.out.print((char)x);
        }
        System.out.println();
    }
}

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

int main()
{
    int  n, x, ans;
    cin >> n >> x;
    int m[n];
    for(int i = 0; i<n; i++){
        cin >> m[i];
        x -= m[i];
    }
    sort(m, m+n);
    ans = n + x / m[0];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
# AOJ 0566: Soccer
# Python3 2018.6.30 bal4u

n = int(input())
m = n*(n-1)>>1
team = [[0 for j in range(3)] for i in range(n)] #[id,win,lost]
for i in range(n): team[i][0] = i
for i in range(m):
	a, b, c, d = map(int, input().split())
	a, b = a-1, b-1
	if   c > d: team[a][1] += 3
	elif c < d: team[b][1] += 3
	else:
		team[a][1] += 1
		team[b][1] += 1
team.sort(key=lambda x:(-x[1],x[0]))
team[0][2] = 1
for i in range(1, n):
	if team[i][1] == team[i-1][1]: team[i][2] = team[i-1][2]
	else: team[i][2] = i+1
team.sort()
for i in range(n): print(team[i][2])


Measured memory_bytes: 5632
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import random
import re
import string
import sys
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from functools import lru_cache, reduce
from math import gcd
from operator import add, itemgetter, mul, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

N, K = list(map(int, sys.stdin.buffer.readline().split()))


cnt = [0] * (N + 1)
for _ in range(K):
    d = int(sys.stdin.buffer.readline())
    A = list(map(int, sys.stdin.buffer.readline().split()))
    for a in A:
        cnt[a] += 1
ans = cnt.count(0) - 1
print(ans)


Measured memory_bytes: 27076
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,k;cin >> n >> k;
  vector<int> vec(n);
  for (int i=0;i<k;i++) {
    int d;cin >> d;
	for (int j=0;j<d;j++) {int f;cin >> f;vec[f-1]++;}
  }
  int count=0;
  for (int i=0;i<n;i++) if (vec[i]==0) count++;
  cout << count << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define to(x) edge[x][i].v
#define mp make_pair
#define rint register int
#define debug(x) cerr<<#x<<"="<<x<<endl
#define fgx cerr<<"-------------"<<endl
#define N 1000000
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
pii go[N]; int id[1000][1000],head[2][N],vis[2][N],col[2][N],tot[2],num[10],T;
struct Edge{int v,next;Edge(int _v=0,int _n=0):v(_v),next(_n){}}edge[2][N*10];
inline void add(int p,int x,int y){edge[p][++tot[p]]=Edge(y,head[p][x]);head[p][x]=tot[p];}
void dfs(int p,int x,int c)
{	vis[p][x]=1; col[p][x]=c;
	for(rint i=head[p][x];i;i=edge[p][i].next)
	if(!vis[p][to(p)]) dfs(p,to(p),c^1); else if(col[p][to(p)]==col[p][x]) assert(0);
}
vector<pii> q1,q2;
int main()
{	int n,d1,d2,cur,t=0,x,y; cin>>n>>d1>>d2;
	for(rint i=0;i<n+n;i++)
	for(rint j=0;j<n+n;j++) id[i][j]=++t,go[t]=mp(i,j);
	for(rint i=0;i<n+n;i++)
	for(rint j=0;j<n+n;j++)
	{	if(i*i+j*j==d1) q1.push_back(mp(i,j));
		if(i*i+j*j==d2) q2.push_back(mp(i,j));
	}
	for(rint i=0;i<n+n;i++)
	for(rint j=0;j<n+n;j++)
	{	for(rint k=0;k<q1.size();k++)
		{	x=i+q1[k].first,y=j+q1[k].second;
			if(0<=x&&x<n+n&&0<=y&&y<n+n) add(0,id[i][j],id[x][y]);
			x=i-q1[k].first,y=j+q1[k].second;
			if(0<=x&&x<n+n&&0<=y&&y<n+n) add(0,id[i][j],id[x][y]);
			x=i+q1[k].first,y=j-q1[k].second;
			if(0<=x&&x<n+n&&0<=y&&y<n+n) add(0,id[i][j],id[x][y]);
			x=i-q1[k].first,y=j-q1[k].second;
			if(0<=x&&x<n+n&&0<=y&&y<n+n) add(0,id[i][j],id[x][y]);
		}
		for(rint k=0;k<q2.size();k++)
		{	x=i+q2[k].first,y=j+q2[k].second;
			if(0<=x&&x<n+n&&0<=y&&y<n+n) add(1,id[i][j],id[x][y]);
			x=i-q2[k].first,y=j+q2[k].second;
			if(0<=x&&x<n+n&&0<=y&&y<n+n) add(1,id[i][j],id[x][y]);
			x=i+q2[k].first,y=j-q2[k].second;
			if(0<=x&&x<n+n&&0<=y&&y<n+n) add(1,id[i][j],id[x][y]);
			x=i-q2[k].first,y=j-q2[k].second;
			if(0<=x&&x<n+n&&0<=y&&y<n+n) add(1,id[i][j],id[x][y]);
		}
	}
	for(rint i=1;i<=t;i++) if(!vis[0][i]) dfs(0,i,0);
	for(rint i=1;i<=t;i++) if(!vis[1][i]) dfs(1,i,0);
	for(rint i=1;i<=t;i++) num[col[0][i]*2+col[1][i]]++;
	for(rint i=0;i<4;i++)
	if(num[i]>=n*n)
	{	for(rint j=1,now=0;now<n*n&&j<=t;j++)
		if(col[0][j]*2+col[1][j]==i) now++,printf("%d %d\n",go[j].first,go[j].second);
		return 0;
	}
	return 0;
}


Measured memory_bytes: 205696
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <bitset>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

#define PI (3.14159265358979323846)
#define INF (2147483647)
#define INF_LL (9223372036854775807)
#define DIV_NUM (1000000007)


int main() {

	string S;
	cin >> S;

	if (S == "AAA" || S == "BBB") {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}

	return 0;

}

Measured memory_bytes: 256
#include <stdio.h>

typedef struct _card {
	int number;
	char suit;
} CARD;

CARD A[100000], I[100000];

void exchange(CARD *a, CARD *b);
int Partition(CARD A[], int p, int r);
void Quicksort(CARD A[], int p, int r);

int main(void) {
	int n;
	char str[20];
	int stable = 1;
	int i, j, c, d;
	
	scanf("%d", &n);
	
	for (i = 0; i < n; ++i) {
		scanf("%s", str);
		A[i].suit = str[0];
		scanf("%d", &A[i].number);
		I[i] = A[i];
	}
	
	Quicksort(A, 0, n - 1);
	
	for (i = 0; i < n; ++i) {
		if (i == 0) {
			c = 0;
		} else if (A[i].number != A[i - 1].number) {
			c = 0;
		} else {
			++c;
		}
		d = 0;
		for (j = 0; j < n; ++j) {
			if (I[j].number == A[i].number) {
				if (c == d) {
					if (I[j].suit != A[i].suit) {
						stable = 0;
					}
					break;
				}
				++d;
			}
		}
		if (stable == 0) {
			break;
		}
	}
	
	if (stable == 1) {
		puts("Stable");
	} else {
		puts("Not stable");
	}
	
	for (i = 0; i < n; ++i) {
		printf("%c %d\n", A[i].suit, A[i].number);
	}
	
	return 0;
}

void exchange(CARD *a, CARD *b) {
	CARD t = *a;
	*a = *b;
	*b = t;
}

int Partition(CARD A[], int p, int r) {
	CARD x = A[r];
	int i = p - 1;
	int j;
	for (j = p; j < r; ++j) {
		if (A[j].number <= x.number) {
			++i;
			exchange(&A[i], &A[j]);
		}
	}
	exchange(&A[i + 1], &A[r]);
	return i + 1;
}

void Quicksort(CARD A[], int p, int r) {
	int q;
	if (p < r) {
		q = Partition(A, p, r);
		Quicksort(A, p, q - 1);
		Quicksort(A, q + 1, r);
	}
}

Measured memory_bytes: 2172
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
int N, M;
ll K;
ll A[200001], B[200001];

int main() {
  INCANT;
  cin >> N >> M >> K;
  rep(i, N) cin >> A[i];
  rep(i, M) cin >> B[i];
  ll sm=0ll;
  int a_idx=0;
  int b_idx=0;
  rep(i, N) {
    if (K >= sm+A[i]) {
      sm+=A[i];
      a_idx++;
    } else break;
  }
  rep(i, M) {
    if (K >= sm+B[i]) {
      sm+=B[i];
      b_idx++;
    } else break;
  }
  int max_cnt = a_idx+b_idx;
  ll rest = K-sm;
  for (int i=a_idx-1; i>=0; i--) {
    rest+=A[i];
    while(b_idx<=M-1 && B[b_idx]<=rest) {
      rest-=B[b_idx];
      b_idx++;
    }
    max_cnt = max(max_cnt, i+b_idx);
  }
  cout << max_cnt << endl;
  return 0;
}

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define eb emplace_back
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define LB(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define UB(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef unsigned long long ull;
typedef long double ld; 
typedef tuple<int,int,int> State;

ll mod = 1e9 + 7;

#define citc(tc) int tc; cin>>tc; while(tc--){solve();}
#define each(a,x) for( auto &a:(x))
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rep2(i, l, r) for (ll i = (l); i < (r); i++)
#define rep2r(i, l, r) for (ll i = (r) - 1; i >= (l); i--)
#define range(a) a.begin(), a.end()
#define deb(x) cout<<#x<<" "<<x<<endl;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cinai(a, n) vi a(n); rep(i, n) { cin>>a[i]; }
#define cinal(a, n) vl a(n); rep(i, n) { cin>>a[i]; }
#define coutai(a, n) rep(i, n) { cout<<a[i]<<" "; } ent;
#define coutal(a, n) rep(i, n) { cout<<a[i]<<" "; } ent;
#define ent cout<<endl;

void solve()
{
	ll a, b;
	cin>>a>>b;
	if(a == b)
		cout<<"Yes\n";
	else
		cout<<"No\n";
}
int main()
{
	fastio();
	// citc(tc);
	solve();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Sz(a) ((int)(a).size())
const int maxn = 200009;
const int MOD = 1e9 + 7;
int main(){
#ifdef LOCAL
  freopen("a.in", "r", stdin);
#endif
  ios_base::sync_with_stdio(false),cout.tie(0),cin.tie(0);
  int n,x;
  cin>>x>>n;
  vector<int> in(200);
  for(int i=0;i<n;++i){
    int a;cin>>a;
    in[a]=1;
  }
  for(int i=0;;++i){
    if(x-i<0||!in[x-i]){
      cout<<x-i<<'\n';return 0;
    }else if(x+i>100||!in[x+i]){
      cout<<x+i<<'\n';return 0;
    }
  }
  
  return 0;
}
//2020.06.14 20:30:39


Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <stack>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
using namespace std;

int main(){
    int x, y, s, ink[10][10] = {{0}};
    while (scanf("%d,%d,%d", &x, &y, &s) != EOF) {
    	if (s == 1){
    		ink[x][y]++;
    		if (x-1 >= 0) ink[x-1][y]++;
    		if (x+1 < 10) ink[x+1][y]++;
    		if (y-1 >= 0)ink[x][y-1]++;
    		if (y+1 < 10)ink[x][y+1]++;
    	} else if (s == 2){
    		for (int i = -1; i <= 1; i++)
    			for (int j = -1; j <= 1; j++)
    				if (x+i >= 0 && x+i < 10 && y+j >= 0 && y+j < 10) ink[x+i][y+j]++;
    	} else {
    		for (int i = -1; i <= 1; i++)
    			for (int j = -1; j <= 1; j++)
    				if (x+i >= 0 && x+i < 10 && y+j >= 0 && y+j < 10) ink[x+i][y+j]++;
    		if (x-2 >= 0) ink[x-2][y]++;
    		if (x+2 < 10) ink[x+2][y]++;
    		if (y-2 >= 0) ink[x][y-2]++;
    		if (y+2 < 10) ink[x][y+2]++;
    	}
    }
    int max = -1, ct = 0;
    REP(i, 10){
    	REP(j, 10){
    		if (max < ink[i][j]) max = ink[i][j];
    		if (ink[i][j] == 0) ct++;
    	}
    }

    cout << ct << endl << max << endl;
}


Measured memory_bytes: 3120
#include <iostream>

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

using namespace std;

static const int LIM = 1000000;
bool np[LIM / 2];

bool is_prime(int n)
{
	return n == 2 || (n % 2 == 1 && !np[n/2]);
}

int main()
{
	np[0] = true;
	for (int i = 3; i * i < LIM; i += 2)
		if (!np[i/2])
			for (int j = 3 * i; j < LIM; j += 2 * i) np[j/2] = true;

	int N;
	while (cin>>N)
	{
		int c = 0;
		rep(i,N+1)
			if (is_prime(i)) c++;
		cout << c << endl;
	}
	return 0;
}

Measured memory_bytes: 1356
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define pb push_back
#define ub upper_bound
#define lb upper_bound
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define ve vector
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
 
using ll = long long;
const ll INF = LLONG_MAX - 100;
ll mod = 1e9 + 7;
int dx[] = {-1,0,1,0}, dy[] = {0,1,0,-1};
vector<ll> prime;

class fact {
public:
	int fmod = 1e9+7;
	vector<int> fac, inv;
	fact (int n, int Mod = 1e9+7) {
		fmod = Mod;
		fac = vector<int>(n,0);
		inv = vector<int>(n,0);
		fac[0] = 1; for (int i = 1; i < n; i++) fac[i] = fac[i-1] * i % fmod;
		for (int i = 0;i < n;i++) inv[i] = fact::POW(fac[i],fmod-2);
	}
	ll nCr(ll n, ll r) {return (fac[n] * inv[r] % fmod) * inv[n-r] % fmod;}
	ll POW(ll a, ll b) {ll c = 1; while (b > 0) {if (b & 1) {c = a * c%fmod;}a = a * a%fmod; b >>= 1;}return c;}
};
 
template <class T = ll> T in() {T x; cin >> x; return (x);}
void DEBUG(vector<int> a) {for(int i=0;i<a.size();i++)cout<<a[i]<<" ";cout<<endl;}
void EMP(int x) {cout<<"!!!"<<x<<"!!!"<<endl;}
ll GCD(ll a, ll b) {ll c; while (b != 0) {c = a % b; a = b; b = c;}return a;}
ll LCM(ll a, ll b) {return a * b / GCD(a, b);}
ll POW(ll a, ll b) {ll c = 1; while (b > 0) {if (b & 1) {c = a * c%mod;}a = a * a%mod; b >>= 1;}return c;}
void PRI(ll n) {bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) {a[i] = 1LL;}for (int i = 2; i < n + 1LL; i++) {if (a[i]) {prime.pb(i); ll b = i; while (b <= n) {a[b] = 0; b += i;}}}}
template <typename T> T chmin(T& a, T b) {if(a>b)a=b;return a;}
template <typename T> T chmax(T& a, T b) {if(a<b)a=b;return b;}

bool solve() {
	int n; cin >> n;
	int d[n]; REP (i,n) cin >> d[i];
	sort(d,d+n);
	int time[n+1]; time[0] = 0;
	int gap = INF;
	REP (i,n) {
		int tmp[2];
		REP (j,2) {
			tmp[j] = INF;
			int hugo = pow(-1,j);
			int ntime = 24 + hugo * d[i]; ntime %= 24;
			REP (k,i+1) {
				int sa = abs(time[k]-ntime); if (sa > 12) sa = 24 - sa;
				tmp[j] = min(tmp[j],sa);
			}
		}
		if (tmp[0] < tmp[1]) {
			time[i+1] = 24-d[i];
		} else time[i+1] = d[i];
		gap = min(gap,max(tmp[0],tmp[1]));
	}
	// REP (i,n) cout << time[i] << endl;
	cout << gap << endl;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
}


Measured memory_bytes: 256
using System;
class Program
{
    static void Main()
    {
        int hun5, five;
        int ans;
        int coin = int.Parse(Console.ReadLine());

        hun5 = coin / 500;
        five = (coin % 500) / 5;

        ans = hun5 * 1000 + five * 5;
        Console.WriteLine(ans);

    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
#define REP(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for(ll (i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for(ll (i) = (m); (i) < (n); (i)++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

template <uint MD> struct ModInt {
    using M = ModInt;
    const static M G;
    uint v;
    ModInt(ll _v = 0) { set_v(uint(_v % MD + MD)); }
    M& set_v(uint _v) {
        v = (_v < MD) ? _v : _v - MD;
        return *this;
    }
    explicit operator bool() const { return v != 0; }
    M operator-() const { return M() - *this; }
    M operator+(const M& r) const { return M().set_v(v + r.v); }
    M operator-(const M& r) const { return M().set_v(v + MD - r.v); }
    M operator*(const M& r) const { return M().set_v(uint(ull(v) * r.v % MD)); }
    M operator/(const M& r) const { return *this * r.inv(); }
    M& operator+=(const M& r) { return *this = *this + r; }
    M& operator-=(const M& r) { return *this = *this - r; }
    M& operator*=(const M& r) { return *this = *this * r; }
    M& operator/=(const M& r) { return *this = *this / r; }
    bool operator==(const M& r) const { return v == r.v; }
    M pow(ll n) const {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
    M inv() const { return pow(MD - 2); }
    friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; }
};
using Mint = ModInt<1000000007>;

const double PI = 3.14159265358979323846;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main()
{	
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    double theta = PI*(6*m - 0.5*(60*h+m)) / 180;
    double ans = a*a + b*b - 2*a*b*cos(theta);

    cout << fixed << setprecision(15);
    cout << sqrt(ans) << endl;
}


Measured memory_bytes: 4192
#include<stdio.h>

int S[100000], T[50000], C = 0;

void binarysearch(int,int,int);

int main(){
    //??\???
    int n, q;
    scanf("%d",&n);
    //printf("%d\n",n);
    for(int i = 0; i < n; i++){
        scanf("%d",&S[i]);
        //printf("%d ",S[i]);
    }//S??????????????????????????????
    //printf("\n");
    scanf("%d",&q);
    //printf("%d\n",q);
    for(int j = 0; j < q; j++){
        scanf("%d",&T[j]);
        //printf("%d ",T[j]);
        
    }
    //printf("\n");//T??????????????????????????????
    
   
    for(int k = 0; k < q; k++){
        binarysearch(0,n,T[k]);
    }
    printf("%d\n",C);
    return 0;
}


void binarysearch(left,right,key){
    int mid = (left + right)/2;
    if(left < right){
        if (S[mid] == key){
            //printf("%d ",mid);
            C++;
        }
        else{
            if(S[mid] < key){
                binarysearch(mid+1,right,key);
            }
            else{
                binarysearch(left, mid,key);
            }
        }
    }
}

Measured memory_bytes: 2368
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1e+9
#define MOD 1000000007
using namespace std;


int main(){
    string S;
    cin >> S;
    if(S=="KIHBR" || S=="AKIHBR" || S=="KIHABR" || S=="KIHBAR" || S=="KIHBRA" || S=="AKIHABR" || S=="AKIHBAR" || S=="AKIHBRA" || S=="KIHABAR" || S=="KIHABRA" || S=="KIHBARA" || S=="AKIHABAR" || S=="AKIHABRA" || S== "AKIHBARA" || S=="KIHABARA" || S=="AKIHABARA"){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    return 0;
}


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

#define ll long long
#define ldb long double
#define rep(i, x, n, j) for(int i=x;i<(int)n;i+=j)
#define F first
#define S second
#define per(i, x, n, j) for(int i=(int)n-1;i>=0;i-=j)
#define all(v) v.begin(),v.end()
#define sz(a) (int)a.size()

const int N = 2000100;
const ll MOD = 1e9+7;
const ll inf = 1e18+5;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;

int _;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll h, w, n; cin >> h >> w >> n;
	cout << ceil((n*1.0)/(1.0*max(h, w))) << endl;
	return 0;
}


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

using namespace std;

int main(void){

    int n, m, count = 0;

    cin >> n >> m;

    vector<int> l(m), r(m);

    for(int i = 0;i < m;i++){
        cin >> l[i] >> r[i];
    }

    int max = *max_element(l.begin(), l.end());
    int min = *min_element(r.begin(), r.end());

    if(max <= min){
        cout << min - max + 1 << endl;
    }else{
        cout << 0 << endl;
    }

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
#define inf 0x3f3f3f3f
#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 2e5+5;
const ll mod =   1e9+7;

int main()
{  fast
int x;
cin>>x;
x=x^1;
cout<<x;
}

Measured memory_bytes: 3644
use proconio::input;

fn main() {
    input! {
        n: usize,
        mut aa: [usize; n],
    }

    aa.sort();
    let max = aa.pop().unwrap();
    let mid = (max+1) / 2;
    let mut ans = 0;

    for a in aa {
        if mid >= a {
            ans = a;
        } else {
            if mid - ans > a - mid {
                ans = a;
            }
            break;
        }
    }

    println!("{} {}", max, ans);
}


Measured memory_bytes: 4192