akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int n;
int x[24],y[24],r[24],c[24];
bool memo[1<<24];
char bit_count[1<<24];

bool ok(int a,int bit){
    for(int i=0;i<a;i++){
        if(((bit>>i)&1)==0)continue;
        int dist=(x[i]-x[a])*(x[i]-x[a])+(y[i]-y[a])*(y[i]-y[a]);
        int sum=(r[i]+r[a])*(r[i]+r[a]);
        if(dist<sum)return false;
    }
    return true;
}

int dfs(int bit){
    memo[bit]=true;

    int ret=n-bit_count[bit];

    for(int i=0;i<n;i++){
        if(((bit>>i)&1)==0||ok(i,bit)==false)continue;
        for(int j=i+1;j<n;j++){
            if(((bit>>j)&1)==0||ok(j,bit)==false||c[i]!=c[j])continue;
            int to_bit=(bit^(1<<i))^(1<<j);
            if(memo[to_bit]==false)ret=max(ret,dfs(to_bit));

        }
    }

    return ret;
}

void solve(){
    fill_n(memo,1<<n,false);

    cout<<dfs((1<<n)-1)<<endl;
}

bool input(){
    cin>>n;
    if(!n)return false;
    for(int i=0;i<n;i++)cin>>x[i]>>y[i]>>r[i]>>c[i];
    return true;
}

void init(){
    for(int i=0;i<(1<<24);i++){
        for(int j=0;j<24;j++)if((i>>j)&1){
            bit_count[i]++;
        }
    }
}

int main(){
    init();
    while(input())solve();
    return 0;
}

Measured memory_bytes: 33928
''' ===============================
	-- @uthor : Kaleab Asfaw
	-- Handle : kaleabasfaw2010
	-- Bio    : High-School Student
	==============================='''

# Fast IO
import sys
import os
from io import BytesIO, IOBase
BUFSIZE = 8192
class FastIO(IOBase):
	newlines = 0
	def __init__(self, file): self._fd = file.fileno(); self.buffer = BytesIO(); self.writable = "x" in file.mode or "r" not in file.mode; self.write = self.buffer.write if self.writable else None
	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b: break
			ptr = self.buffer.tell(); self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
		self.newlines = 0; return self.buffer.read()
	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)); self.newlines = b.count(b"\n") + (not b); ptr = self.buffer.tell(); self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
		self.newlines -= 1; return self.buffer.readline()
	def flush(self):
		if self.writable: os.write(self._fd, self.buffer.getvalue()); self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
	def __init__(self, file): self.buffer = FastIO(file); self.flush = self.buffer.flush; self.writable = self.buffer.writable; self.write = lambda s: self.buffer.write(s.encode("ascii")); self.read = lambda: self.buffer.read().decode("ascii"); self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout); input = lambda: sys.stdin.readline().rstrip("\r\n")
# Others
# from math import floor, ceil, gcd
# from decimal import Decimal as d
mod = 10**9+7
def lcm(x, y): return (x * y) / (gcd(x, y))
def fact(x, mod=mod):
	ans = 1
	for i in range(1, x+1): ans = (ans * i) % mod
	return ans
def arr2D(n, m, default=0):
	lst = []
	for i in range(n): temp = [default] * m; lst.append(temp)
	return lst
def sortDictV(x): return {k: v for k, v in sorted(x.items(), key = lambda item : item[1])}

def solve(n):
	cnt = 0
	for i in range(1, n):
		val = n // i
		if n % i == 0: val -= 1
		cnt += val
	return cnt

n = int(input())
print(solve(n))

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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

int N, C, K;

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

  cin >> N >> C >> K;
  vector< int > T(N);
  REP(i, N)
    cin >> T[i];

  sort(ALL(T));

  int limit = T[0] + K;
  int cnt = 0;
  int ans = 0;
  REP(i, N) {
    cnt++;
    /*
    debug(T[i]);
    debug(i);
    debug(cnt);
    debug(ans);
    debug(limit);
    */
    if (T[i] > limit) {
      cnt = 1;
      if (i < N - 1) {
	limit = T[i] + K;
      }
      ans++;
    }
    if (cnt == C) {
      cnt = 0;
      ans++;
      limit = T[i + 1] + K;
    }
    /*
    debug(i);
    debug(cnt);
    debug(ans);
    debug(limit);
    */
  }

  if (cnt > 0) ans++;
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int maxA = 0, maxB = 0, minA = 0, minB = 0;
        
        for(int i = 0; i < N; i++) {
            int A = scan.nextInt();
            int B = scan.nextInt();
            
            if(i == 0) {
                maxA = A;
                minA = A;
                maxB = B;
                minB = B;
            } else {
                if(B > maxB) {
                    maxA = A;
                    maxB = B;
                }
                if(B < minB) {
                    minA = A;
                    minB = B;
                }
            }
        }
        int count = minA;
        for(int i = minB; i > 0; i--) count++;
        
        System.out.println(count);
    }
}


Measured memory_bytes: 62612
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define F               first
#define S               second
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18 + 1
#define endl            '\n'
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define forI(i,a,n)     for(int i=a;i<=n;i++)
#define forD(i,a,n)     for(int i=n;i>=a;i--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
void init(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}

int dp[3001][3001][2];

int compute(int *a, int i, int j, int turn){
    if(i > j)   return 0;

    if(dp[i][j][turn] != -1)    return dp[i][j][turn];

    if(turn)
        return dp[i][j][turn] = max(a[i] + compute(a, i+1, j, 0), a[j] + compute(a, i, j-1, 0));
    else
        return dp[i][j][turn] = min(compute(a, i+1, j, 1), compute(a, i, j-1, 1));
}

void solve(){
    int sum=0, n;  cin>>n;
    mk(a, n+1, int);    forI(i, 1, n)   cin>>a[i];
    memset(dp, -1, sizeof dp);
    forI(i, 1, n)   sum += a[i];
    int x = compute(a, 1, n, 1);
    int y = sum - x;

    cout<<(x-y)<<endl;
}   

int32_t main(){
    init();
    // w(t) 
    solve();
    return 0;
}

Measured memory_bytes: 144524
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

n = INT()

m = [-1] * (n+1)
m[0] = 1
m[1] = 1

def fib(n):
    if m[n] != -1:
        return m[n]
    
    ans = fib(n-1) + fib(n-2)
    m[n] = ans
    return ans

print(fib(n))
    



Measured memory_bytes: 5600
use proconio::{input, fastout};
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
  }

#[fastout]
fn main() {
    input!{
        x: usize,
        y: usize,
    }

    println!("{}", x+y/2);

}


Measured memory_bytes: 2200
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll N=1e5+5;
vector<ll> adj[N];
ll n,m,q,ans[N],vis[N][15],v[N],d[N],c[N];
void dfs(ll u,ll d,ll c){
    if(vis[u][d])return;
    vis[u][d]=1;
    if(d==0){
        ans[u]=c;
        return;
    }
    dfs(u,d-1,c);
    for(auto &v:adj[u])
        dfs(v,d-1,c);
}
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin>>n>>m;
    for(ll i=0,u,v;i<m;i++)cin>>u>>v,adj[u].push_back(v),adj[v].push_back(u);
    cin>>q;
    for(ll i=0;i<q;i++)cin>>v[i]>>d[i]>>c[i];
    for(ll i=q-1;i>=0;i--)dfs(v[i],d[i],c[i]);
    for(ll i=1;i<=n;i++)cout<<ans[i]<<"\n";
}


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

int main(void){

    int n;
    long long ans = 0;
    cin >> n;
    int A[n+1];
    int B[n];
    
    for(int i = 0; i <= n; i++) cin >> A[i];
    
    for(int i = 0; i < n; i++)  cin >> B[i];


    for(int i = 0; i < n; i++){
        
        if(B[i] == 0) continue;

        if(B[i] <= A[i]){
            ans += B[i];
            continue;
        }

        if(B[i] <= A[i] + A[i+1]){
            ans += B[i];
            B[i] -= A[i];
            A[i + 1] -= B[i];
            continue;
        }
        
        ans += A[i] + A[i + 1];
        A[i + 1] = 0;
    
    }

    cout << ans << endl;
    

}


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

int main()
{
	int n, k, d, x, c = 0;
	map<int, int> m;
	cin >> n >> k;
	for(int i=1; i<=n; i++){
		m[i]=0;
	}
	while (k--)
	{
		cin >> d;
		for (int i = 0; i < d; i++)
		{
			cin >> x;
			m[x]++;
		}
	}
	for (auto it = m.begin(); it != m.end(); it++)
	{
		if (it->second == 0)
		{
			c++;
			// return it->first
		}
	}
	cout << c << endl;

	return 0;
}

Measured memory_bytes: 3200
/*
 * atcoder/abc169/d.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

vector<pair<ll, ll> > prime_factorize(ll n) {
  vector<pair<ll, ll> > res;
  for (ll p = 2; p * p <= n; ++p) {
    if (n % p != 0) continue;
    int num = 0;
    while (n % p == 0) { ++num; n /= p; }
    res.push_back(make_pair(p, num));
  }
  if (n != 1) res.push_back(make_pair(n, 1));
  return res;
}
template<class T1, class T2>
T1 intpow(const T1& a, const T2 n) {
  if (n == 0) return 1;
  auto t = intpow(a, n / 2);
  t = t * t;
  if (n & 1) t = t * a;
  return t;
}

/*
 * 素因数分解して、1つの素因数の累乗で出来るものを小さい順に並べて小さい方からNを割っていく.
 * 次の数で割れなくなったら終了
 * count = 0
 * for i in ?:
 *     z = 素数を正の整数eで累乗した数、かつNの約数
 *     z not in setZ
 *     N //= z
 *     count += 1
 */
ll N;
vector<ll> A;
void solve() {
  cin >> N;
  auto P = prime_factorize(N);
  for (auto&&p: P) {
    for (int i=1; i<=p.second; i++) {
      A.push_back(intpow(p.first, i));
    }
  }
  sort(A.begin(), A.end());

  ll count = 0;
  int idx = 0;
  while (N > 1 and idx < A.size()) {
    if (N%A[idx] != 0) { idx++; continue; }
    N /= A[idx++];
    count++;
  }

  cout << count << endl;
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


Measured memory_bytes: 3632
import java.util.*;
public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long cnt[] = new long[5];
        for(int i=0; i<n; i++){
            String s = sc.next();
            if(s.charAt(0)=='M'){
                cnt[0] += 1;
            }else if(s.charAt(0)=='A'){
                cnt[1] += 1;
            }else if(s.charAt(0)=='R'){
                cnt[2] += 1;
            }else if(s.charAt(0)=='C'){
                cnt[3] +=1;
            }else if(s.charAt(0)=='H'){
                cnt[4] +=1;
            }else{

            }
        }
        long ans = 0;
        for(int i=0; i<3; i++){
            for(int j=i+1; j<4; j++){
                for(int k=j+1; k<5; k++){

                    ans += cnt[i]*cnt[j]*cnt[k];
                }
            }
        }
        System.out.println(ans);
    }
}


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

int main()
{
    ll H, W; cin >> H >> W;
    vector<string> S(H, "");
    rep(i,H) {
        cin >> S[i];
    }
    vector<string> S2;
    rep(i, H) {
        bool allw = true;
        rep(j, W) {
            if (S[i][j] == '#') {
                allw = false;
                break;
            }
        }
        if (allw == false) {
            S2.push_back(S[i]);
        }
    }
    map<ll,ll> eraser;
    rep(i, W) {
        bool allw = true;
        rep(j, S2.size()) {
            if (S2[j][i] == '#') {
                allw = false;
                break;
            }
        }
        if (allw) {
            eraser[i] = 1;
        }
    }
    rep(i,S2.size()) {
        rep(j,W) {
            if (eraser[j]) continue;
            cout << S2[i][j];
        }
        cout << endl;
    }
}


Measured memory_bytes: 3632
#include <iostream>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

int main() {
  int A, B, C, D;
  int T;
  cin >> T;
  D = T % 10;
  T /= 10;
  C = T % 10;
  T /= 10;
  B = T % 10;
  A = T / 10;

  char op1, op2, op3;
  bool flag = false;
  rep(i, 2) {
    rep(j, 2) {
      rep(k, 2) {
        int ans = 0;
        if (i == 0) {
          ans = A + B;
          op1 = '+';
        }
        else {
          ans = A - B;
          op1 = '-';
        }
        if (j == 0) {
          ans += C;
          op2 = '+';
        }
        else {
          ans -= C;
          op2 = '-';
        }
        if (k == 0) {
          ans += D;
          op3 = '+';
        }
        else {
          ans -= D;
          op3 = '-';
        }
        if (ans == 7) {
          if (!(flag)) cout << char(A + '0') << op1 << char(B + '0') << op2 << char(C + '0') << op3 << char(D + '0') << "=7" << endl;
          flag = true;
        }
      }
    }
  }

}


Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    n = ri()
    s = input()
    bc = '!'
    ans = 0
    for c in s:
        if c != bc:
            ans += 1
        bc = c
    print(ans)


if __name__ == '__main__':
    main()


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

int main() {
  int n;
  cin >> n;
  
  int pro = 1;
  int ans = 1;
  
  for (int i = 0; i < 7; i++) {
    pro *= 2;
    if (pro <= n) {
      ans = pro;
    }
    else {
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long a,b;
char op;
int main()
{
    scanf("%lld %c %lld",&a,&op,&b);
    if(op=='+')
    {
        printf("%lld\n",a+b);
    }
    else
    {
         printf("%lld\n",a-b);
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#include<functional>
//#include<bits/stdc++.h>
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
const ld pi = 3.141592653589793238;
//printf("%.10f\n", n);

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll modpow(ll x, ll y) {
	ll res = 1;
	while (y) {
		if (y % 2) { res *= x; res %= mod; }
		x = x * x % mod; y /= 2;
	}
	return res;
}

ll test[12345678];
signed main() {
	/*ll n, x, l, q, a = 0, b = 0, c = 0, d = 0, ans = 0; cin >> n >> x;
	for (int h = 0; h < n; h++) {
		cin >> test[h];
		if (test[h] % 2 == 0) { a++; }
		else { b++; }
	}
	b /= 2; a += b;
	cout << modpow(2, a) << endl;*/
	ll D, c, s; cin >> D;
	for (int h = 0; h < 26; h++) {
		cin >> c;
	}
	for (int i = 0; i < D; i++) {
		for (int h = 0; h < 26; h++) {
			cin >> s;
		}
	}
	for (int h = 0; h < D; h++) {
		cout << 1 << endl;
	}
	return 0;
}

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

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

using namespace std;
using lint = long long;

int main(void)
{
    lint N;
    lint A, B;
    cin >> N;
    cin >> A >> B;
    lint ans = N/(A+B) * A + min(N % (A+B), A);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    REP(i,n)cin >> a[i];
    SORT(a);
    REP(i,n-1){
        if(a[i]==a[i+1]){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>

int main(void)
{
   int n, i, flag;
   char s[100];
   flag=1;
   scanf("%s",s);
   n=strlen(s);
   for(i=0; i<n/2; i++){
      if(s[i]!=s[n-1-i])
         flag=0;
      if(flag==0)
         i=n;
   }
   if(flag)
      for(i=0; i<n/2; i++){
      if(s[i]!=s[(n-3)/2-i])
         flag=0;
      if(flag==0)
         i=n;
   }
   if(flag!=0)
      for(i=(n+1)/2;i<n;i++){
         if(s[i]!=s[n-1-i]) flag=0;
         if(flag==0) i=n;
      }

   if(flag!=0) printf("Yes\n");
   else        printf("No\n");

   return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<(int)(n);i++)
#define N 200000

int main(){
	long long x, y, z;
	long long ans;
		scanf("%lld %lld %lld", &z, &x, &y);
		if (y - x > 2){
			if ((x - 1) > z){
				printf("%lld\n", z + 1);
				return 0;
			}
			z -= x - 1;
			ans = x;
			ans += (z % 2);
			ans += ((y - x)*(z / 2));
			printf("%lld\n", ans);

			return 0;
		}
		printf("%lld\n", z + 1);
		return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <tuple>
#include <cstring>
#include <map>
#include <iomanip>
#include <ctime>
#include <complex>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define len(X) (X).size()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tiii tuple<int, int, int>
#define Tlll tuple<ll, ll, ll>

int main() {
    int h, w;
    cin >> h >> w;
    int c[100][100];
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> c[i][j];
        }
    }
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            int b;
            cin >> b;
            c[i][j] -= b;
            //cerr << c[i][j] << " ";
        }
        //cerr << endl;
    }
    
    bool dp[h][w][40000] = {};
    dp[0][0][c[0][0] + 20000] = 1;
    dp[0][0][-c[0][0] + 20000] = 1;
    for (int i = 1; i <= h + w; i++) {
        for (int hi = 0; hi <= i; hi++) {
            int wi = i - hi;
            if (hi >= h || wi < 0 || wi >= w) continue;

            if (hi != 0) {
                for (int j = 0; j < 40000; j++) {
                    if (dp[hi - 1][wi][j] && 0 <= j + c[hi][wi] && j + c[hi][wi] <= 40000) {
                        dp[hi][wi][j + c[hi][wi]] = 1;
                        //cout << hi _ wi _ j << endl;
                    }
                    if (dp[hi - 1][wi][j] && 0 <= j - c[hi][wi] && j - c[hi][wi] <= 40000) {
                        dp[hi][wi][j - c[hi][wi]] = 1;
                        //cout << hi _ wi _ j << endl;
                    }
                }
            }
            if (wi != 0) {
                for (int j = 0; j < 40000; j++) {
                    if (dp[hi][wi - 1][j] && 0 <= j + c[hi][wi] && j + c[hi][wi] <= 40000) {
                        dp[hi][wi][j + c[hi][wi]] = 1;
                        //cout << hi _ wi _ j << endl;
                    }
                }
                for (int j = 0; j < 40000; j++) {
                    if (dp[hi][wi - 1][j] && 0 <= j - c[hi][wi] && j - c[hi][wi] <= 40000) {
                        dp[hi][wi][j - c[hi][wi]] = 1;
                        //cout << hi _ wi _ j << endl;
                    }
                }
            }
        }
    }

    int ans = 1e9;
    for (int i = 0; i < 40000; i++) {
        if (dp[h - 1][w - 1][i]) {
            ans = min(ans, abs(i - 20000));
            //cout << i - 20000 << endl;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 250240
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vstring vector<string>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 100000000

int main(){
  ll x,y;
  cin >> x >> y;
  ll count = 0;
  while(x <= y){
    count++;
    x *= 2;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
h = list(map(int,input().split()))
cnt = [0]*n
chk = [0]*n
ans = 0

for i in range(m):
  a,b = map(int, input().split())
  if h[a-1] > h[b-1]:
    cnt[a-1] += 1
  elif h[a-1] < h[b-1]:
    cnt[b-1] += 1
  chk[a-1] += 1
  chk[b-1] += 1
  
for i in range(n):
  if cnt[i] == chk[i]:
    ans += 1
    
print(ans)

Measured memory_bytes: 85016
///////////////////////////////////////////////////////////
#include <algorithm>
#include <array>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
///////////////////////////////////////////////////////////
#define ll long long
#define ull unsigned lon long
///////////////////////////////////////////////////////////
int absolute(int n); double absolute(double n);
void input(vector<int>& vec);
void print(vector<int> vec); void print(vector<double> vec);
int sum(vector<int> vec); double sum(vector<double> vec);
void upsort(vector<int>& vec);
void downsort(vector<int>& vec);
int maxvec(vector<int> vec);
int minvec(vector<int> vec);
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
int main()
{
    int n;
    cin >> n;
    vector<int>a(n),b(n);
    input(a);
    for(int i=1;i<=n;++i){
        b.at(a.at(i-1)-1)=i;
    }
    print(b);
    return 0;
}
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
int absolute(int n)
{
    if (n < 0) {
        return (-n);
    }
    return n;
}

double absolute(double n)
{
    if (n < 0) {
        return (-n);
    }
    return n;
}

void input(vector<int>& vec)
{
    for (size_t i = 0; i < vec.size(); ++i) {
        cin >> vec.at(i);
    }
}

void print(vector<int> vec)
{
    for (size_t i = 0; i < vec.size(); ++i) {
        cout << vec.at(i) << " ";
    }
    cout << endl;
}

void print(vector<double> vec)
{
    for (size_t i = 0; i < vec.size(); ++i) {
        cout << vec.at(i) << " ";
    }
    cout << endl;
}

int sum(vector<int> vec)
{
    int s = accumulate(vec.begin(), vec.end(), 0);
    return s;
}

double sum(vector<double> vec)
{
    double s = accumulate(vec.begin(), vec.end(), 0.0);
    return s;
}

void upsort(vector<int>& vec)
{
    sort(vec.begin(), vec.end());
}

void downsort(vector<int>& vec)
{
    sort(vec.begin(), vec.end(), greater<int>());
}

int maxvec(vector<int> vec)
{
    int m = vec.at(0);
    for (size_t i = 0; i < vec.size(); ++i) {
        m = max(m, vec.at(i));
    }
    return m;
}

int minvec(vector<int> vec)
{
    int m = vec.at(0);
    for (size_t i = 0; i < vec.size(); ++i) {
        m = min(m, vec.at(i));
    }
    return m;
}
///////////////////////////////////////////////////////////

Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1 LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
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 (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)
struct UnionFind {  // UnionFind uni(N);
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<int> siz; // 素集合のサイズを表す配列(1 で初期化)

    UnionFind(int N) : par(N), siz(N, 1){ //最初は全てが根であるとして初期化、頂点数N
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
        siz[ry] += siz[rx];
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int size(int x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

int main() {
    LL N,M;cin >> N >> M;
    vector<LL> A(M);
    vector<LL> B(M);
    vector<LL> C(M);

    rep(i,M){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        A[i] = a;
        B[i] = b;
    }
    UnionFind uni(N);

    
    for(int i = M-1;i >= 0;--i){
        if(uni.same(A[i],B[i])){
            C[i] = 0;
            continue;
        }
        LL a = uni.size(A[i]);
        LL b = uni.size(B[i]);
        LL tmp = (a * b);
        C[i] = tmp;
        uni.unite(A[i],B[i]);
    }

    LL sum = 0;
    rep(i,M){
        sum += C[i];
        cout << sum << endl;
    } 
}

Measured memory_bytes: 4480
package main

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

const (
	maxBufSize = 1024 * 1024
)

var (
	sc = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, 1)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
	out = bufio.NewWriter(os.Stdout)
)

func isEvenString(s string) bool {
	l := len(s)
	return s[0:l / 2] == s[l/2:]
}

func solve(s string) int {
	l := len(s)
	for i := l - 2; ; i -= 2 {
		if isEvenString(s[0:i]) {
			return i
		}
	}
	return 0
}

func main() {
	defer out.Flush()

	s := next()
	res := solve(s)
	fmt.Fprintln(out, res)
}

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

func nextStringAsBytes() []byte {
	sc.Scan()
	return []byte(sc.Text())
}

func nextInt() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int64) []int64 {
	ret := make([]int64, n)
	for i := int64(0); i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}

func nextFloats(n int64) []float64 {
	ret := make([]float64, n)
	for i := int64(0); i < n; i++ {
		ret[i] = nextFloat()
	}
	return ret
}
func nextStrings(n int64) []string {
	ret := make([]string, n)
	for i := int64(0); i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func containStr(arr []string, target string) bool {
	for _, v := range arr {
		if v == target {
			return true
		}
	}
	return false
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "orz")
	}
}

// mapからkeysとvaluesを返す
func splitKeyValue(m map[interface{}]interface{}) (keys, values []interface{}) {
	switch reflect.TypeOf(m).Kind() {
	case reflect.Map:
		s := reflect.ValueOf(m)
		for _, v := range s.MapKeys() {
			keys = append(keys, v)
			values = append(values, s.MapIndex(v))
		}
	default:
		fmt.Fprintln(out, "orz")
	}
	return
}


Measured memory_bytes: 1784
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy



vl getDegrees(ll x){
  vl degrees;
  ll i = 2;
  while(i<x+1){
    ll r = 0;
    while(x%i == 0){
      r++;
      x /= i;
    }
    degrees.pb(r);
    i++;
  }
  return degrees;
}

ll divisorNumber(ll x){
  vl divdegrees = getDegrees(x);
  ll ans = 1;
  F0R(i,divdegrees.size()){
    ans *= (divdegrees[i]+1);
  }
  return ans;
}

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

    ll n;
    cin >> n;
    ll ans = 0;
    for(int i=1;i < n+1; i+=2){
      if(divisorNumber(i) == 8 && i)
        ans ++;
    }
    cout << ans << endl;
    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
#include<utility>
#include<map>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1001001001;

ll pow_mod(ll p, ll n, ll m) {
	if (n == 0) return 1;
	else if (n == 1) return p % m;
	else if (n % 2 == 1) return p * pow_mod(p, n - 1, m) % m;
	else {
		ll tmp = pow_mod(p, n / 2, m);
		return (tmp * tmp) % m;
	}
}

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

ll com_mod(ll n, ll k, ll m) {
	if (k == 0) return 1;
	else {
		ll x = 1;
		ll y = 1;
		for (ll i = 0; i < k; i++) {
			x = (x * (n - i)) % m;
			y = (y * (i + 1)) % m;
		}
		ll res = (x * pow_mod(y, m - 2, m)) % m;
		return res;
	}
}

int main() {
	string s; cin>>s;
	for (int i = 0; i < 3; i++) {
		if (s[i] == '1') s[i] = '9';
		else if (s[i] == '9') s[i] = '1';
	}
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int n, m, cnt[5], c[100005];
vector<int> g[100005];

void dfs(int cur, int col) {
	if (c[cur] == -1) {
		c[cur] = col;
		cnt[col]++;
		FOR(i, g[cur].size()) {
			dfs(g[cur][i], col^1);
		}
	}
	else if (c[cur] == col^1) {
		cout << 1LL*n*(n-1)/2-m << endl;
		exit(0);
	}
}

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n >> m;
	FOR(i, m) {
		int u, v;
		cin >> u >> v;
		g[u-1].push_back(v-1);
		g[v-1].push_back(u-1);
	}
	MEM(c, -1);
	dfs(0, 0);
	cout << 1LL*cnt[0]*cnt[1]-m << endl;
	return 0;
}

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

using namespace std;

int main()
{
    int n, tm;
    cin >> n >> tm;
    vector<int> c(n);
    vector<int> t(n);
    for (int i = 0; i < n; ++i) {
        cin >> c[i] >> t[i];
    }
    int min = 1001;
    for (int i = 0; i < n; ++i) {
        if (tm >= t[i]) {
            if (min > c[i]) min = c[i];
        }
    }
    if (min == 1001) cout << "TLE" << endl;
    else cout << min << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

template<class T>
vector<T> rerooting(vector<vector<ll>> G, function<T(T,T)> merge, T id){
    ll N = G.size();
    vector<T> V(N); // 各頂点の値
    vector<map<ll, T>> dp(N);

    auto dfs = [&](auto&& dfs, ll now, ll par, bool flag) {
        if (dp[now].count(par)) return dp[now][par];

        ll gn = G[now].size();
        if(par == -1 or flag){
            vector<T> A;
            for (ll i = 0; i < gn; i++){
                ll to = G[now][i];
                if (to == par) continue;

// 
                A.emplace_back(dfs(dfs, to, now, flag) + 1);
            }

            ll an = A.size();
            vector<T> R(an + 1, id);  //右からの累積和
            for (ll i = an; i > 0; i--) R[i - 1] = merge(R[i], A[i - 1]);

            if(par == -1){
                T L = id;
                for (ll i = 0; i < gn; i++){
                    ll to = G[now][i];

                    dp[now][to] = merge(L, R[i + 1]);  //now->toを除いた値
                    L = merge(L, A[i]);  //左から累積していく
                }
            }

            return dp[now][par] = R[0];

        }
        else{
            dfs(dfs, now, -1, flag);
            return dfs(dfs, now, par, flag);
        }
    };

    dfs(dfs, 0, -1, true);

    for (ll i = 0; i < N; i++) dfs(dfs, i, -1, false), V[i] = dp[i][-1];

    return V;
}

int main() {
    init();
    ll N, M;
    cin >> N >> M;
    vvc<ll> G(N);
    rep(i, N - 1){
        ll a, b;
        cin >> a >> b;
        a--, b--;
        G[a].eb(b), G[b].eb(a);
    }

    vl ans = rerooting<ll>(G, [&](ll a, ll b) { return a * b % M; }, 1);

    rep(i, N) cout << ans[i] << '\n';
}

Measured memory_bytes: 55004
#include <numeric>
#include <iostream>
#include <array>
#include <string>
#include <vector>
#include <cassert>
#include <algorithm>
#include <math.h> 
#include <set>
#include <map>
#include <utility>
#include <deque>
#include <queue>


using namespace std;

#define ll long long int
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repp(i, n) for(int i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define riverse(v) reverse((v).begin(), (v).end())
#define pb push_back
#define mp make_pair
#define all(a)  (a).begin(),(a).end()
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvvi = vector<vi>;
const ll MOD = 1e9 + 7;
vi alphabet = { 'a','b','c','d','e','f','g','h','i','j','k','l','m',
               'n','o','p','q','r','s','t','u','v','w','x','y','z' };




int main() {
    int n, h;
    cin >> n >> h;
    vi a(n);
    vi b(n);
    vi copy(n);
    rep(i, n) {
        cin >> a[i];
        cin >> b[i];
        copy[i] = a[i];
    }
    sort(copy);
    riverse(copy);
    int maxa = copy[0];
    int sumb = 0;
    int count = 0;
    sort(b);
    riverse(b);
    for (int x : b) {
        if (x > maxa) {
            h -= x;
            count++;
            if (h <= 0)break;
        }
    }
    if (h <= 0) cout << count << endl;
    else {
        if (h % maxa != 0) {
            count += h / maxa;
            count++;
        }
        else count += h / maxa;
        cout << count << endl;
    }
}

Measured memory_bytes: 1536
def main():
    D = int(input())
    C = list(map(int, input().split()))
    S = []
    for i in range(D):
        S.append(list(map(int, input().split())))

    last = [0]*26
    ans = []
    for d in range(D):
        score = -100*365
        t = 0
        for i in range(26):
            tmp = S[d][i]
            for j in range(26):
                if i != j:
                    tmp -= C[j]*(d + 1 - last[j])
            if tmp > score:
                score = tmp
                t = i + 1
        last[t - 1] = d + 1
        ans.append(t)
    print('\n'.join(map(str, ans)))

if __name__ == '__main__':
    main()


Measured memory_bytes: 9512
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main(){
    FIN;
    ll x; cin >> x;
    ll ans_a,ans_b;

    for(ll a=-1000;a<=1000;a++){
        for(ll b=-1000;b<=1000;b++){
            if(pow(a,5) - pow(b,5) == x){
                ans_a = a;
                ans_b = b;
                break;
            }
        }
    }


    cout << ans_a << " " << ans_b << endl;
    return 0;
}



Measured memory_bytes: 3988
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] chars = sc.next().toCharArray();
		boolean easy = true;
		for(int i = 0; i < chars.length; i++){
			if(i % 2 == 0){
				if(chars[i] == 'L'){
					easy = false;
				}
			}else{
				if(chars[i] == 'R'){
					easy = false;
				}
			}
		}
		System.out.println(easy ? "Yes" : "No");
	}
}


Measured memory_bytes: 21972
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
long long MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    long long power = 1;
    for(int i=1; i<=n; i++) {
        power = (power*i) % MOD;
    }
    cout << power << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
using namespace std;
int arr[205];
int main()
{
    int N, L;
    cin >> N >> L;
    int sum = 0;
    for(int i = 1; i <= N; i++) {
        arr[i] = L + i - 1;
        sum += arr[i];
    }
    int res = 0;
    int mx = -100000000;
    for(int i = 1; i <= N; i++) {
        res = 0;
        for(int j = 1; j <= N; j++) {
            if(i != j) {
                res += arr[j];
            }
        }
        //cout << "res = " << res << "\n";
        if(abs(res) <= abs(sum)) {
            mx = max(mx, abs(res) );
        }
    }
    if(sum < 0) cout << "-" << mx << "\n";
    else cout << mx << "\n";
    return 0;
}


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

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

  // ここにプログラムを追記
  int l, r;
  int audience = 0;
  
  for (int i = 0; i < N; i++) {
    cin >> l >>r;
    
    if (l == r) {
      audience += 1;
    } else {
   	  audience += r - l + 1;
    }    
  }
  
  cout << audience <<endl;
}



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

int left(int i)
{
    return 2 * i;
}

int right(int i)
{
    return 2 * i + 1;
}

int parent(int i)
{
    return i / 2;
}

const int maxn = 256;
int a[maxn];

int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    for (int i = 1; i <= n; i++)
    {
        cout << "node " << i << ": key = " << a[i] << ", ";
        if (parent(i) >= 1) cout << "parent key = " << a[parent(i)] << ", ";
        if (left(i) <= n) cout << "left key = " << a[left(i)] << ", ";
        if (right(i) <= n) cout << "right key = " << a[right(i)] << ", ";
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3068
'''
x = 0
while (x+1)**5 - x**5 < 1000000000:
    x += 1
print(x)
'''
maximum = 120
minimum = -120

x = int(input())

for i in range(minimum+1, maximum):
    for j in range(minimum, maximum-1):
        if i**5 - j**5 == x:
            a = i
            b = j

print(a, b)


Measured memory_bytes: 9180
import java.util.*;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        int N = Integer.parseInt(scanner.next());
        int[][] c = new int[10][10];
        for (int i = 1; i <= N; i++) {
            int s = i;
            while (s > 9) s /= 10;
            int e = i % 10;
            c[s][e]++;
        }

        int ans = 0;
        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) {
                ans += c[i][j] * c[j][i];
            }
        }

        System.out.println(ans);
    }

}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
int J[1010][1010],O[1010][1010],I[1010][1010];
int main(){
	int n,m,k;	cin>>m>>n>>k;
	memset(J,0,sizeof(J));	memset(O,0,sizeof(O));	memset(I,0,sizeof(I));
	for(int i=1;i<=m;i++){
		string s;	cin>>s;
		for(int j=1;j<=n;j++){
			if(s[j-1]=='J')	J[i][j]=1;
			else if(s[j-1]=='O')	O[i][j]=1;
			else I[i][j]=1;
			J[i][j]+=J[i-1][j]+J[i][j-1]-J[i-1][j-1];
			O[i][j]+=O[i-1][j]+O[i][j-1]-O[i-1][j-1];
			I[i][j]+=I[i-1][j]+I[i][j-1]-I[i-1][j-1];
		}
	}
	/*
	for(int i=1;i<=m;i++){
		for(int j=1;j<=n;j++)	cout<<J[i][j]<<" ";
		cout<<endl;
	}
	cout<<endl;
	for(int i=1;i<=m;i++){
		for(int j=1;j<=n;j++)	cout<<O[i][j]<<" ";
		cout<<endl;
	}
	cout<<endl;
	for(int i=1;i<=m;i++){
		for(int j=1;j<=n;j++)	cout<<I[i][j]<<" ";
		cout<<endl;
	}
	cout<<endl;
	*/
	for(int t=0;t<k;t++){
		int a,b,c,d;	cin>>a>>b>>c>>d;	a--;	b--;
		int j=J[c][d]-J[a][d]-J[c][b]+J[a][b];
		int o=O[c][d]-O[a][d]-O[c][b]+O[a][b];
		int i=I[c][d]-I[a][d]-I[c][b]+I[a][b];
		cout<<j<<" "<<o<<" "<<i<<endl;
	}
	return 0;
}

Measured memory_bytes: 13168
use std::io::{self, BufRead, Write};

fn solve<R, W>(reader: R, mut writer: W)
where
    R: BufRead,
    W: Write,
{
    let mut lines = reader.lines();
    let a_line = lines.next().unwrap().unwrap();
    let mut splited = a_line.trim().split_whitespace();
    let n: usize = splited.next().unwrap().parse().unwrap();
    let k: i32 = splited.next().unwrap().parse().unwrap();
    let q: i32 = splited.next().unwrap().parse().unwrap();

    let mut points = vec![0; n];
    for l in lines {
        let answered_plus_one: i32 = l.unwrap().trim().parse().unwrap();
        points[(answered_plus_one - 1) as usize] += 1;
    }

    for p in points {
        let ans = if k - q + p > 0 {
            "Yes"
        } else {
            "No"
        };
        writeln!(&mut writer, "{}", ans).unwrap();
    }
}

fn main() {
    let stdio = io::stdin();
    let input = stdio.lock();

    let output = io::stdout();

    solve(input, output);
}

#[cfg(test)]
mod tests {
    use super::*;

    const TESTS: &'static [(&'static [u8], &'static [u8])] = &[
        (
            br"6 3 4
3
1
3
2", br"No
No
Yes
No
No
No
",
        ),
        (
            br"6 5 4
3
1
3
2", br"Yes
Yes
Yes
Yes
Yes
Yes
",
        ),
        (
            br"10 13 15
3
1
4
1
5
9
2
6
5
3
5
8
9
7
9", br"No
No
No
No
Yes
No
No
No
Yes
No
",
        ),
    ];

    #[test]
    fn test_c() {
        for &(input, expected) in TESTS {
            let mut output = Vec::new();
            solve(input, &mut output);
            let expected_str = String::from_utf8(expected.to_vec()).unwrap();
            let output_str = String::from_utf8(output).unwrap();
            assert_eq!(expected_str, output_str);
        }
    }
}


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

int main()
{
    int N, M; cin >> N >> M;
    vector<ll> a(N), c(M), d(N);
    vector<int> b(M);
    vector< pair<ll,int> > pairs(M);
    ll sum = 0;
    ll ans = 0;
    for(int i=0;i<N;i++) {
        cin >> a[i];
        sum += a[i];    
    }
    ans = sum;
    for(int i=0;i<M;i++) {
        cin >> b[i] >> c[i];
        pairs[i] = make_pair(c[i],b[i]);
    }
    sort(a.begin(),a.end());
    sort(pairs.begin(),pairs.end(),greater<pair <int,int> >());
    int j=0;
    for(int i=0;i<N;i++){
        if(pairs[j].second == 0) j++;
        d[i] = pairs[j].first;
        pairs[j].second--;
    }
    for(int i=0;i<N;i++){
        sum = sum + d[i] - a[i];
        if(sum > ans) ans = sum;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4608