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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x,y; cin>>x>>y;
    if (abs(x-y)<=1){
        cout<<"Brown\n";
    }else{
        cout<<"Alice\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define SPEED ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define RFOR(i, b, a) for (ll i = b; i >= a; --i)
#define ALL(x) x.begin(), x.end()
#define DEBUG(args...) { string _s = #args; replace(ALL(_s), ' ', '\0');\
replace(ALL(_s), ',', ' ');\
stringstream _ss(_s); istream_iterator<string> _it(_ss); _debug(_it, args);}
#define endl "\n"
#define F first
#define S second
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)

using namespace std;
using namespace __gnu_pbds;

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

void _debug(istream_iterator<string>) {}
template<typename T, typename... Args>
void _debug(istream_iterator<string> it, T first, Args... args) {
    cerr << ">> " << *it << " : " << first << endl; _debug(++it, args...);
}
template <typename T1, typename T2>
inline ostream& operator << (ostream& out, const pair<T1, T2>& p) {
    return out << "(" << p.F << ", " << p.S << ")";
}
template<typename T>
inline ostream& operator << (ostream& out, const vector<T>& v) {
    if (v.empty()) return out << "[]";
    else { out << '['; for (auto& e : v) { out << e << ", "; } return out << "\b\b]"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const set<T>& s) {
    if (s.empty()) return out << "{}";
    else { out << '{'; for (auto& e : s) { out << e << ", "; } return out << "\b\b}"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const unordered_set<T>& s) {
    return out << set<T>(ALL(s));
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const map<T1, T2>& m) {
    if (m.empty()) return out << "{}";
    out << '{'; for (auto& p : m) { out << p << ", "; } return out << "\b\b}";
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const unordered_map<T1, T2>& m) {
    return out << map<T1, T2>(ALL(m));
}
template<typename T>
inline ostream& operator << (ostream& out, const ordered_set<T>& s) {
    return out << set<T>(ALL(s));
}

typedef long long ll;
typedef long double ld;
typedef vector<long long> vll;
typedef pair<ll, ll> pll;
typedef vector<pair<ll, ll>> vpll;
typedef unordered_map<ll, ll> STll;
/************************************** MAIN PROGRAM ********************************************/

int main()
{
    //freopen("input.txt", "r", stdin);
    SPEED
    ll n, d;
    cin >> n >> d;
    ll range = d * 2 + 1;
    cout << (n + range - 1) / range;
}
/************************************** END OF PROGRAM ******************************************/
/** Stuff you should look for:
 * int overflow, array bounds, over-counting, graph is not a tree/connected
 * special cases (n=1?), set/unordered_set TLE, multi-set/set error
 * do something instead of nothing and stay organized
 */


Measured memory_bytes: 256
//dp[v]:当一种颜色的子树权重为x[v]时，另一种颜色权重的最小值
//dp01[i]:当一种颜色的子树权重为i时，另一种颜色权重的最小值
//所以dp[] = min(dp01[1], dp01[2]...)
#include<bits/stdc++.h>

using namespace std;

const int maxn = 1001;
const int maxxi = 5001;
const int INF = 0x3F3F3F3F;

int n;
int x[maxn];
int f[maxn];
int dp[maxn];
int dp01[maxxi];
vector<int> kids[maxn];

void dfs(int root) {
	if(!kids[root].size()) {
		dp[root] = 0;
		return;
	}
	for(vector<int> :: iterator it = kids[root].begin(); it != kids[root].end(); it++) {
		dfs(*it);
	}
	memset(dp01, INF, sizeof(dp01)); //01backpack
	dp01[0] = 0;
	for(vector<int> :: iterator it = kids[root].begin(); it != kids[root].end(); it++) {
		int k = *it;
		for(int i = x[root]; i >= 0; i--) {
			int tmp = INF;
			if(i >= x[k]) { //k = same colour as root
				tmp = min(tmp, dp01[i - x[k]] + dp[k]);
			}
			if(i >= dp[k]) { //k = diff colour as root
				tmp = min(tmp, dp01[i - dp[k]] + x[k]);
			}
			dp01[i] = tmp;
		}
	}
	for(int i = x[root]; i >= 0; i--) {
		dp[root] = min(dp[root], dp01[i]);
	}
}

int main() {
	memset(dp, INF, sizeof(dp));
	scanf("%d", &n);
	for(int i = 2; i <= n; i++) {
		scanf("%d", f + i);
		kids[f[i]].push_back(i);
	}
	for(int i = 1; i <= n; i++) {
		scanf("%d", x + i);
	}
	dfs(1);
	if(dp[1] < INF) {
		printf("POSSIBLE\n");
	} else {
		printf("IMPOSSIBLE\n");
	}
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define all(t) (t).begin(),(t).end()
#define MOD 1000000007
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}

int main(){
	ll n,l,q;
	ll x[100010];
	cin >> n;
	vector<ll> v;
	v.push_back(-1);
	FOR(i,n){cin >> x[i];v.push_back(x[i]);}
	cin >> l >> q;
	v.push_back(10000000000000);
	ll p[100010][20];
	FOR(i,n){
		if(i==n-1){p[i][0]=n;break;}
		ll a=upper_bound(all(v),x[i]+l)-v.begin();
		p[i][0]=a-2;
	}
	p[n][0]=n;
	for(int i=1;i<=19;i++){
		FOR(j,n+1){
			p[j][i]=p[p[j][i-1]][i-1];
			
		}
	}
	
	
	FOR(i,q){
		ll a,b;
		cin >> a >> b;
		a--;b--;
		if(a>b)swap(a,b);
		ll ans=0;
		for(int i=19;i>=0;i--){
			if(p[a][i]<b){
				ans+=1<<i;
				a=p[a][i];
			}	
		}
		cout << ans+1 << endl;
	}
}

Measured memory_bytes: 18164
from collections import Counter

n, k = map(int, input().split())
a = [int(i) for i in input().split()]

a.sort()
cnt = dict(Counter(a))
cnt = sorted(cnt.items(), key = lambda x : x[1])

if len(set(a)) <= k:
  print(0)
  exit()

ans = 0
h = len(set(a)) - k
for i in range(h):
  ans += cnt[i][1]

print(ans)

Measured memory_bytes: 41360
L,R=map(int,input().split())
if L//2019<R//2019:
  print(0)
else:
  L,R=L%2019,R%2019
  if L > R:
    print(0)
  else:
    import heapq
    import itertools
    l=[]
    for i,j in itertools.combinations(range(L,R+1),2):
      heapq.heappush(l,(i*j)%2019)
    print(heapq.heappop(l))

Measured memory_bytes: 75592
# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

# include <stdio.h>
# include <bits/stdc++.h>


#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

using namespace __gnu_pbds;
using namespace std;
 
typedef
tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;

inline bool isvowel (char c) {
	c = tolower(c);
    if (c == 'a' || c == 'e' || c == 'i' || c == 'y' || c == 'o' || c == 'u') return 1;
    return 0;
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int cnt[N];
string s;
int a[N];
vector < int > g[N];
int u[N];
int ans, res;
int cur;

int main () {
	SpeedForce;

	cin >> s;	
	ll ans = 0;
	for (int i = sz(s) - 1; i >= 0; i --) {  	
		if (s[i] == 'B') {
			cur = 0;
			continue;
		}
		if (s[i] == 'A') {
			ans += cur;
			continue;
		}
		if (s[i] == 'C') {
			if (i > 0 && s[i - 1] == 'B') {
				cur ++;
				i --;
				continue;
			}
			cur = 0;
		}
	}
	cout << ans;

	return Accepted;
}

// B...a

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

int main(){
  int a,b;
  string op;
  cin>>a>>op>>b;

  if(op=="+"){cout<<a+b<<endl;}
  else{cout<<a-b<<endl;}
  
  return 0;
}


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

int main()
{
    vector<int> rl, ud;
    int x, y;
    string s;
    cin >> s;
    cin >> x >> y;
    int len = s.size();
    bool ifrl = true;
    int now = 0;
    int maxx = 0, maxy = 0;
    for(int i = 0; i < len; i++){
        if(s[i] == 'T')
        {
            if(ifrl)
            {
                rl.push_back(now);
                maxx += now;
            }
            else
            {
                ud.push_back(now);
                maxy += now;
            }
            ifrl = !ifrl;
            now = 0;
        }
        else now++;
    }
    if(ifrl)
    {
        rl.push_back(now);
        maxx += now;
    }
    else
    {
        ud.push_back(now);
        maxy += now;
    }
    int n, m;
    n = rl.size();
    m = ud.size();
    int first = rl[0];
    bool dp[20000];
    fill(dp, dp + 20000, false);
    dp[first * 2] = true;
    for(int i = 1; i < n; i++){
        for(int j = maxx * 2; j >= first * 2; j--){
            if(j >= rl[i] * 2) dp[j] = (dp[j] || dp[j - rl[i] * 2]);
        }
    }
    bool lrf = dp[x + maxx];
    fill(dp, dp + 20000, false);
    dp[0] = true;
    for(int i = 0; i < m; i++){
        for(int j = maxy * 2; j >= 0; j--){
            if(j >= ud[i] * 2) dp[j] = (dp[j] || dp[j - ud[i] * 2]);
        }
    }
    bool udf = dp[y + maxy];
    if(lrf && udf) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main() {
	int N;
	long long K;
	std::cin >> N >> K;
	std::vector<int> A(N);
	for (int i = 0; i < N; i++) std::cin >> A[i];

	std::vector<int> arrived;
	std::vector<int> order(N, -1);
	int now_place = 1;
	while (order[now_place - 1] == -1) {
		order[now_place - 1] = arrived.size();
		arrived.push_back(now_place);
		now_place = A[now_place - 1];
	}
	int length = arrived.size();
	int cycle = arrived.size() - order[now_place - 1];

	if (K < length) std::cout << arrived[K] << std::endl;
	else {
		K -= order[now_place - 1];
		K %= cycle;
		std::cout << arrived[order[now_place - 1] + K] << std::endl;
	}
	return 0;
}

Measured memory_bytes: 5780
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 100100100100;
const long long MOD = 1000000007;
typedef pair<long long,long long> P;
//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}
long long nCr(long long n, long long r) {
    long long A = 1, B = 1;
    //Aが分子Bが1/r!
    for (long long i = n - r + 1; i <= n; i++) {
        A = A * i % MOD;
    }
    for (long long i = 1; i <= r; i++) {
        B = B * i % MOD;
    }
    B = mod_pow(B, MOD - 2);
    B %= MOD;
    //Bは割るのではなく掛ける
    return (A * B) % MOD;
}

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

//long long A,B;
bool ok(long long key,long long index){
    if(index > key) return true;
    else if(index <= key) return false;
}
long long binary_search(long long key,long long size){
    //left,right,midはいずれもindex
    long long left = -1,right = size;
    while(right - left > 1){
        long long mid = left + (right-left)/2;
        long long hantei = ok(key,mid);
        if(hantei) right = mid;
        else left = mid;
    }
    if(left == -1)return 0;
    return left;
}

int main() {
    int N;cin >> N;
    vector<int> retu(N);
    vector<int> LEFT(N);
    vector<int> RIGHT(N);
    map<int,int> M_L;
    map<int,int> M_R;
    for(int i = 1;i<=N;i++){
        cin >> retu.at(i-1);
        LEFT.at(i-1) = i + retu.at(i-1);
        M_L[LEFT.at(i-1)]++;
        RIGHT.at(i-1) = i - retu.at(i-1);
        M_R[RIGHT.at(i-1)]++;
    }
    long long ans = 0;
    for(auto A : M_L){
        int index = A.first;
        long long numL = A.second;
        long long numR = M_R[index];
        ans += numL*numR;
    }

    cout << ans << endl;

    
    


    

    // PLEASE GIVE ME THE "ACCEPTED" !
}


Measured memory_bytes: 31176
n = int(input())
a = list(map(int,input().split()))
a.sort()
ans = 1
if a[0] == 0:
  print(0)
else:
  for i in range(len(a)):
    ans *= a[i]
    if ans > 10**18:
      print("-1")
      exit()
    elif i == len(a)-1:
      print(ans)

Measured memory_bytes: 21632
#include <bits/stdc++.h>
using namespace std;
typedef long long lo;
typedef vector<lo> vl;
typedef vector<vl>vll;
#define all(v) (v).begin(), (v).end()
#define debug(x) cerr<<#x<<" = "<<x<<endl;
#define REPV(a, b, c) for (lo(a) = b; (a) < (c); (a)++) 
#define REP(a,b) for(lo i =(a) ;i<(b);i++)

template <typename T>

istream &operator>>(istream &in, vector<T> &v)
{
	for (unsigned i = 0; i < v.size(); i++)
		in >> v[i];
	return in;
}


void solve(){
		lo N,K; cin>>N>>K; vl v(N); cin>>v;
		lo x = 1;
		for(int i=0;i<K;i++)x+=v[i];
		lo l = 0,prev = 0;
		prev = x;
		for(int i = K;i<N;i++){
			x = x-v[l++];
			x=x+v[i];
			if(prev<x){
				
				prev = x;
				cout<<"Yes"<<endl;
				
			}
			else {
				prev = x;
				cout<<"No"<<endl;}
			
		}
		
	
		
}


int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout.precision(20);
	solve();
	return 0;
}

Measured memory_bytes: 4704
def hamming_numbers(max)
  nums = Array.new(max + 1, 0)
  nums[1] = 1

  (2..max).each do |num|
    nums[num] = 1 if num % 2 == 0 && nums[num / 2] == 1
    nums[num] = 1 if num % 3 == 0 && nums[num / 3] == 1
    nums[num] = 1 if num % 5 == 0 && nums[num / 5] == 1
  end

  (1..max).select { |num| nums[num] == 1 }
end

nums = hamming_numbers(1_000_000)

while line = gets
  break if line.chomp == '0'
  m, n = line.chomp.split.map(&:to_i)
  puts nums.take_while { |num| num <= n }.size - nums.take_while { |num| num < m }.size
end

Measured memory_bytes: 16452
from sys import stdin

input = stdin.readline


def gcd(a, b):
    result = a
    k = 0
    n = b

    while True:
        k = result % n
        result = n
        n = k
        if k == 0:
            break

    return result


def gcd_n(numbers):
    l = numbers[0]

    for i in range(len(numbers)):
        l = gcd(l, numbers[i])

    return l


def lcm(a, b):
    g = gcd(a, b)

    return a * (b / g)


def lcm_n(numbers):
    l = numbers[0]

    for i in range(len(numbers)):
        l = lcm(l, numbers[i])

    return l


N, X = map(int, input().split())

xn = [abs(X - int(i)) for i in input().split()]


def main():
    print(gcd_n(xn))
    return


main()


Measured memory_bytes: 14248
#include<bits/stdc++.h>
#define FOR0(i,n) for(ll i=0;i<n;i++)
#define FOR1(i,n) for(ll i=1;i<=n;i++)
#define FORl(i,l,n) for(ll i=l;i<n;i++)
using namespace std;
#define pi pair<ll,ll>
#define pb push_back
#define ll long long
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define mst0(x) memset(x,0,sizeof(x));
#define vi vector<ll>
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define sp <<" "<<
#define intmax 1e14
#define M 1000000007

ll power(ll num,ll g,ll mod){
  if(g==0)return 1;
  if(g%2==1)return (num*power((num*num)%mod,g/2,mod))%mod;
  return power((num*num)%mod,g/2,mod);
}
 
int main(){
	ll n, k;
	cin>>n>>k;
	vector<ll> vec(k+1);
	vector<ll> temp(k+1);
	FOR1(i, k)	vec[i] = 0; vec[0] = 1;
	while(n--){
		ll a; cin>>a;
		ll sum = 0;
		FOR0(i, k+1){
			sum += vec[i];
			if(i-a-1 >= 0)
				sum -= vec[i-a-1];
			sum %= M;
			temp[i] = sum;
		}
		swap(vec, temp);
	}
	cout<<(vec[k] + M) % M<<"\n";
}

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

struct edge{
  int to,c,t,r;
};
struct state{
  int h,id,c;
  state(int h,int id,int c):h(h),id(id),c(c){}
  state(){}
  bool operator<(const state& st) const {
    return c > st.c;
  }
};

int N,M,H,K;
int S,T,P;
vector<edge> G[111];
#define INF (1<<29)
int flag[(1<<8)];


int mem[26][111];

int solve(int bi){
  fill(mem[0],mem[25],INF);
  priority_queue<state> q;
  q.push( state(0,S,0) );
  mem[0][S] = 0;
  
  while( !q.empty() ){
    state p = q.top(); q.pop();
    if( mem[p.h][p.id] < p.c ) continue;
    if( p.id == T ) return p.c;
    for(int i=0;i<(int)G[p.id].size();i++){
      edge e = G[p.id][i];
      int nc = e.c;
      int nh = p.h + e.t;
      if( nh > H ) continue;
      if( bi & (1<<e.r) ) nc = 0;
      if( mem[nh][e.to] > nc + p.c ) {
	mem[nh][e.to] = nc + p.c;
	q.push( state(nh,e.to,nc + p.c) );
      }
    }
  }
  return -1;
}

int main(){
  while( cin >> N >> M >> H >> K && (N||M||H||K) ){
    for(int i=0;i<N;i++) G[i].clear();
    for(int i=0;i<M;i++){
      int a,b,c,h,r;
      cin >> a >> b >> c >> h >> r;
      --a; --b; --r;
      G[a].push_back( (edge){b,c,h,r} );
      G[b].push_back( (edge){a,c,h,r} );
    }
    
    cin >>  S>> T; --S; --T;
    cin >> P;
    fill(flag,flag+(1<<K),INF);
    flag[0] = 0;
    for(int i=0;i<P;i++){
      int l,f; cin >> l >> f;
      int bit = 0;
      for(int j=0;j<l;j++){
	int k; cin >> k; k--;
	bit |= (1<<k);
      }
      flag[bit] = min( flag[bit], f );
    }
    for(int i=0;i<(1<<K);i++)
      for(int j=0;j<(1<<K);j++)
	flag[i|j] = min( flag[i|j], flag[i]+flag[j] );
    int res = INF;
    for(int i=0;i<(1<<K);i++){
      if( flag[i] >= INF ) continue;
      //   cout << bitset<8>(i)<< " "<< flag[i] << endl;
      int ret = solve(i);
      if( ret != -1 ) res = min( res, flag[i] + ret );
    }
    if( res >= INF) cout << -1 << endl;
    else cout << res << endl;
  }
}

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

int main(void){
  int a, b;
  cin >> a >> b;
  int sum, min, mul;
  sum = a + b;
  min = a - b;
  mul = a * b;
  int max;
  max = sum;
  if(max < min) max = min;
  if(max < mul) max = mul;
  cout << max << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,res=0,flag=0;
    cin>>n;
    while(n>0)
    {
        res=n%10;
        n=n/10;
        if(res==7)
        {
            flag=1;
            break;
        }

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

}


Measured memory_bytes: 3636
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000

typedef long long ll;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

const int L = 16 * 9 * 5 * 7 * 11;

int main(void) {
    int N;
    while (cin >> N && N) {
        int Q[25][25] = {{0}};
        for (int i = 0; i < N; i++) {
            int d, t;
            cin >> d >> t;
            for (int j = 0; j < d; j++) {
                int q;
                cin >> q;
                Q[d][(j+d-t) % d] += q;
            }
        }
        int sum = 0, T[L] = {0};
        for (int d = 1; d <= 24; d++) {
            if (d == 13 || d == 17 || d == 19 || d == 23) {
                int ma = 0;
                for (int i = 0; i < d; i++) ma = max(ma, Q[d][i]);
                sum += ma;
            } else {
                for (int i = 0; i < L; i++) {
                    T[i] += Q[d][i%d];
                }
            }
        }
        int ma = 0;
        for (int i = 0; i < L; i++) ma = max(ma, T[i]);
        cout << sum + ma << endl;
    }
    return 0;
}

Measured memory_bytes: 1384
// 基本テンプレート

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

typedef pair<int, int> pii;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int X, K, Q;

signed main() {
    cin >> X >> K;
    vector<pii> ops;
    rep(i,0,K) {
        int tm; cin >> tm;
        ops.push_back(make_pair(tm, -1));
    }
    cin >> Q;
    rep(i,0,Q) {
        int t, a; cin >> t >> a;
        ops.push_back(make_pair(t, a));
    }

    sort(ops.begin(), ops.end());
    int prev = 0, lb = 0, ub = X;
    int diff = 0, sign = -1;
    rep(i,0,ops.size()) {
        int d = (ops[i].first - prev) * sign;
        diff += d; prev = ops[i].first;
        ub = min(X  , max(0LL, ub + d));
        lb = max(0LL, min(X  , lb + d));
        if(ops[i].second == -1) sign *= -1;
        else {
            int cur = ops[i].second + diff;
            cout << min(ub, max(lb, cur)) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 6512
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
ll MOD = 1000000007;
#define INF (1e9)

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;


int main()
{
    ll N, A, B;
    cin >> N >> A >> B;
    cout << min(N*A, B) << endl;
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/python3

def cnt(C, K):
    c = C // (K - 1)
    if C % (K - 1) > 0:
        c += 1
    return c


def main():
    N, K = [int(e) for e in input().split(' ')]
    A = [int(e) for e in input().split(' ')]
    assert len(A) == N

    op = A.index(1)

    ans = cnt(op, K) + cnt(N - op - 1, K)
    ans = min(ans, cnt(N - 1, K))

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 13880
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *
 
N = INT()

dic = defaultdict(int)

for i in range(1, N+1):
	char = str(i)[0] + str(i)[-1]
	dic[char] += 1

ans = 0
for i in range(1, 10):
	for j in range(1, 10):
		ans += dic[str(i)+str(j)] * dic[str(j)+str(i)]

print(ans)

Measured memory_bytes: 10560
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i).sort
hash = Hash.new(0)
a.each do |i|
    hash[i] += 1
end
hash = hash.to_a
arr = []
while true
    point = hash.pop
    if point[1] >= 2 && point[1] <= 3
        arr << point[0]
    elsif point[1] >= 4
        arr << point[0]
        arr << point[0]
    end
    if hash == []
        break
    end
end
ans = 1
if arr.size >= 2
    2.times do |i|
        ans *= arr.shift
    end
    puts ans
else
    puts "0"
end


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

int main() {
  int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin >> k;
  cout << a[k - 1] << endl;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

struct Solver {
	void solve() {
		int N, M;
		cin >> N >> M;

		vector<int> H( N );
		for( int i = 0; i < N; ++i ) { cin >> H[i]; }

		vector<set<int>> rt( N );
		for( int i = 0; i < M; ++i ) {
			int a, b;
			cin >> a >> b;
			rt[a-1].insert( b-1 );
			rt[b-1].insert( a-1 );
		}

		int ans = 0;
		for( int i = 0; i < N; ++i ) {
			bool ok = true;
			for( int j: rt[i] ) {
				if( H[i] <= H[j] ) {
					ok = false;
					break;
				}
			}
			if( ok ) { ans += 1; }
		}

		cout << ans << endl;
	}
};

int main() {
	ios::sync_with_stdio( false );
	cout << fixed << setprecision( 10 );
	Solver().solve();

	return 0;
}


Measured memory_bytes: 17792
def cul(a, b, c, m):
    result = 0
    for i in range(m):
        result += int(a[i])*int(b[i])

    return 1 if (result+int(c)) > 0 else 0 

N,M,C = map(int, input().split())
b = input().split()
a = [input().split() for _ in range(N)]

ans = 0
for i in range(N):
    ans += cul(a[i], b, C, M)

print(ans)

Measured memory_bytes: 3064
#include<stdio.h>

int main(){
    int K,S,t=0;
    scanf("%d%d",&K,&S);
    for(int i=0;i<=K;i++){
        for(int j=0;j<=K;j++){
           if(i+j<=S && i+j+K>=S){
               t++;
           }
        }
        
    }
    printf("%d",t);

    return 0;
}

Measured memory_bytes: 128
N, K = map(int, input().split())
mod_is_0 = 0
mod_is_half_K = 0
for i in range(1, N+1):
    if i%K == 0:
        mod_is_0 += 1
    if K%2 == 0 and i%K == K/2:
        mod_is_half_K += 1
print(mod_is_0**3+mod_is_half_K**3)

Measured memory_bytes: 39408
#include <stdio.h>
int main(void)
{
    int k, n, d[10], i, cnt=0, tmp, j, ans;

    scanf("%d%d", &n, &k);
    for(i=0;i<k;i++){
        scanf("%d", &d[i]);
    }
    ans=n;

    while(1){
        tmp=ans;
        while(tmp>0){
        cnt=0;
        j=tmp%10;
        for(i=0;i<k;i++){
            if(j==d[i]) break;
            cnt++;
        }
        if(cnt==k) tmp=tmp/10;
        else break;
        }
        if(tmp==0) break;
        ans++;
    }

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


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

int main(){
  string S;
  cin >> S;
  int n = S.size();
  long long sum = 0;

  for (int i = 0; i < (1 << n-1); i++) {
    long long t = S[0]-'0';
    for (int j = 0; j < n-1; j++) {
      if (i & (1 << j)) {
        sum += t;
        t = S[j+1]-'0';
      }
      else {
        t *= 10;
        t += S[j+1]-'0';
     }
    }
    sum += t;
  }
  cout << sum << endl;
  }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    long long int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    pair<long long int,long long int> dp[n][n];
    for(int i=0;i<n;i++)
    {
        pair<long long int,long long int>x = {a[i],0};
        dp[i][i] = x;
    }
    // for(int i=0;i<n;i++)
    // {
    //     for(int j=i+1;j<n;j++)
    //     {
    int k = 1;
    while(k<n)
    {
        int j = k;
        int i = 0;
        while(j<n && i<n)
        {
            pair<long long int,long long int>x;
            long long int a1,b1;
            a1 = max(a[i] + dp[i+1][j].second, a[j] + dp[i][j-1].second);
            b1 = ((a[i] + dp[i+1][j].second ) > (a[j] + dp[i][j-1].second)) ? dp[i+1][j].first : dp[i][j-1].first;
            x = {a1,b1};
            dp[i][j] = x;
            j++;
            i++;
        }
        k++;
    }
    // for(int i=0;i<n;i++)
    // {
    //     for(int j=i;j<n;j++)
    //     {
    //         cout<<"{"<<dp[i][j].first<<","<<dp[i][j].second<<"}  ";
    //     }
    //     cout<<endl;
    // }
    cout<<dp[0][n-1].first - dp[0][n-1].second;
}

Measured memory_bytes: 140928
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define ee endl
#define pii pair<int,int>
#define infinity 10000000000000000
#define mod 1000000007
int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

using namespace std;
///check n=1;
///check corner case;
const int maX=1e5+1;
vector<ll>Graph[maX],cost[maX];
ll visit[maX];
ll x[10];
ll y[10];
double dist(ll i, ll j)
{
    double dx=x[i]-x[j];
    double dy=y[i]-y[j];
    return pow(dx*dx+dy*dy,0.5);
}

int main()
{
    ll a,b,c;cin>>a>>b>>c;
    ll x=a-b;
    cout<<max(0ll,c-x)<<endl;
}


Measured memory_bytes: 4992
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


n, k = LI()
p = LI()
p.sort()
ans = sum(p[:k])
print(ans)


Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

template< class T >
struct CumulativeSum2D {
  vector< vector< T > > data;

  CumulativeSum2D(int W, int H) : data(W + 1, vector< int >(H + 1, 0)) {}

  void add(int x, int y, T z) {
    ++x, ++y;
    if(x >= data.size() || y >= data[0].size()) return;
    data[x][y] += z;
  }

  void build() {
    for(int i = 1; i < data.size(); i++) {
      for(int j = 1; j < data[i].size(); j++) {
        data[i][j] += data[i][j - 1] + data[i - 1][j] - data[i - 1][j - 1];
      }
    }
  }

  T query(int sx, int sy, int gx, int gy) {
    return (data[gx][gy] - data[sx][gy] - data[gx][sy] + data[sx][sy]);
  }
};

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

  int h,w,k;
  cin >> h >> w >> k;
  vector<string> s(h);
  rep(i,h) cin >> s[i];
  CumulativeSum2D<int> sum(h,w);
  rep(i,h){
    rep(j,w){
      if(s[i][j]=='1') sum.add(i,j,1);
    }
  }
  sum.build();
  int ans = h+w-2;
  rep(i,1<<(h-1)){
    int tans = __builtin_popcount(i);
    vector<int> hbound;
    hbound.pb(0);
    rep(j,h-1){
      if(i&(1<<j)) hbound.pb(j+1);
    }
    hbound.pb(h);
    int cl = 0;
    bool ok = true;
    rep(j,w+1){
      rep(l,hbound.size()-1){
	int csum = sum.query(hbound[l],cl,hbound[l+1],j);
	//		cout << "sx sy gx gy sum" << hbound[l] << " " << cl << " " << hbound[l+1] << " " << j << " "<< csum << endl;
	if(csum > k){
	  tans++;
	  if(j==cl+1) ok=false;
	  else{
	    cl = j-1;
	    j--;
	    break;
	  }
	}
      }
    }
    if(ok){
      //      rep(i,hbound.size()) cout << hbound[i] << " \n"[i==hbound.size()-1];
      //      cout << "ans " << tans << endl;
      ans = min(ans,tans);
    }
  }
  cout << ans << endl;


  
  return 0;
    

}


Measured memory_bytes: 384
X, Y, Z, K = [int(i) for i in input().split()]

A = sorted([int(i) for i in input().split()], reverse=True)
B = sorted([int(i) for i in input().split()], reverse=True)
C = sorted([int(i) for i in input().split()], reverse=True)

Anum = 0
Bnum = 0
Cnum = 0

AB = []
for i in range(X):
    for j in range(Y):
        AB.append(A[i]+B[j])

AB = sorted(AB, reverse=True)
AB = AB[:min(X*Y,K)]

ABC = []
for i in range(len(AB)):
    for j in range(Z):
        ABC.append(AB[i]+C[j])

ABC = sorted(ABC, reverse=True) 

for i in range(K):
    print(int(ABC[i]))


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

int main()
{
    std::string s;
    std::cin >> s;
    int n  = s.size();

    int res = 0;
    for(int i = 0; i < n; i++){
        int cnt = 0;
        for(int j = i; j < n; j++){
            if(s[j] != 'A' && s[j]!= 'C' && s[j] != 'G' && s[j] != 'T')break;
            cnt++;
        }
        res = std::max(cnt,res);
        
    }
    std::cout << res << std::endl;
}

Measured memory_bytes: 256
/*
	Copyright: razouq (c)
	Author: Anass BENDARSI
	Date: 07/01/2018 12:43:30
	flamers will **** you
*/
#include<bits/stdc++.h>
//#include<flamers.h>
#define ll long long
#define ull unsigned long long
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define POB pop_back
#define dist(a, b) sqrt(a*a + b*b)
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pair<int, int>> vipi;
bool compare(pi p1, pi p2){
	 if(1) return true;
	 return false;
}

int main(){
//	freopen("input.in", "r", stdin);
//	freopen("output.out", "w", stdout);
	ios::sync_with_stdio(0);
	cin.tie();
	long long n, h;
	cin>>n>>h;
	vector<pair<long long, bool>> vect;
	long long a, b;
	for(int i = 0; i < n; i++){
		cin>>a>>b;
		vect.PB({a, true});
		vect.PB({b, false});
	}
	sort(vect.rbegin(), vect.rend());
	long long res = 0, index = 0;
	while(h > 0){
		if(vect[index].S == false) {
			h -= vect[index].F;
			index++;
			res++;
		}		
		else {
			res += (h + vect[index].F - 1) / vect[index].F;
			break;
		}
		
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 6128
#include<cstring>
#include<iostream>
using namespace std;
char a[110][110];
int b[110][110];
int main()
{
    int t=0;
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            cin>>a[i][j];
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            if(a[i][j]=='#')
                b[i][j]=-1;
            else if(a[i][j]=='.')
            {
                for(int k=i-1;k<=i+1;k++)
                    for(int l=j-1;l<=j+1;l++)
                        if(a[k][l]=='#')
                            t++;
                b[i][j]=t;
                t=0;
            }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++)
            if(a[i][j]=='.')
                cout<<b[i][j];
            else cout<<'#';
        cout<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <numeric>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vl = vector<ll>;  // long longの1次元の型に vl という別名をつける
using vvl = vector<vl>; // long longの2次元の型に vvl という別名をつける
int MOD = 1000000007; //10^9 + 7

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// 無限大の値
const ll  LINF = 1LL << 60;
const int iINF = 1 << 29;

int main(void){
  char a,b;
  cin >> a >> b;
  const string s = "HD";
  int i = a==s[0] ? 0 : 1;
  cout << (b==s[0] ? s[i] : s[1-i]) << endl;
  return 0;
} 

Measured memory_bytes: 3560
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
template<class S, class T> inline S max_L(S a,T b){
  return a>=b?a:b;
}
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    my_putchar_unlocked('-');
  }
  while(s--){
    my_putchar_unlocked(f[s]+'0');
  }
}
int N;
int K;
int A[200000];
int main(){
  long long ok;
  long long res;
  rd(N);
  rd(K);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=(0);Lj4PdHRW<(N);Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  long long e98WHCEY;
  long long cTE1_r3A;
  long long RZTsC2BF;
  e98WHCEY = 1;
  {
    int FmcKpFmN;
    int xr20shxY;
    if(N==0){
      xr20shxY = 0;
    }
    else{
      xr20shxY = A[0];
      for(FmcKpFmN=(1);FmcKpFmN<(N);FmcKpFmN++){
        xr20shxY = max_L(xr20shxY, A[FmcKpFmN]);
      }
    }
    cTE1_r3A =xr20shxY;
  }
  while(e98WHCEY < cTE1_r3A){
    int i;
    if((e98WHCEY + cTE1_r3A)%2==0){
      RZTsC2BF = (e98WHCEY + cTE1_r3A) / 2;
    }
    else{
      RZTsC2BF = (e98WHCEY + cTE1_r3A - 1) / 2;
    }
    ok = 0;
    for(i=(0);i<(N);i++){
      ok += (A[i]-1) / RZTsC2BF;
    }
    if(ok <= K){
      cTE1_r3A = RZTsC2BF;
    }
    else{
      e98WHCEY = RZTsC2BF + 1;
    }
  }
  res =cTE1_r3A;
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20200509-1

// --- original code ---
// int N, K, A[2d5];
// {
//   ll ok, res;
//   rd(N,K,A(N));
//   res = bsearch_min[ll,x,1,max(A(N))][
//     ok = 0;
//     rep(i,N) ok += (A[i]-1) / x;
//   ](ok <= K);
//   wt(res);
// }


Measured memory_bytes: 5348
fun readLineInt(): Int {
    val str: String? = readLine()
    return if (str == null) 0 else str.toInt()
}

fun main(arg: Array<String>) {
    val x: Int = readLineInt()
    val a: Int = readLineInt()
    val b: Int = readLineInt()
    val rest: Int = x - a
    val num: Int = rest / b
    println(rest - num * b)
}


Measured memory_bytes: 31952
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    string s; cin >> s;
    int num_e=0, num_o=0;
    for(int i=0; i<s.size(); ++i){
        int c=s[i]-'0';
        num_e+=c!=i%2;
        num_o+=c!=(i+1)%2;
    }
    cout << min(num_e, num_o) << endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <limits>

#define ll long long

using namespace std;

ll dp[1 << 25];
int dp2[2][1 << 25];

inline int countbit(ll k) {
	int q = 0;
	for (ll i = 1, j = 0; j <= 60; i *= 2, j++) {
		if ((i&k) > 0)q++;
	} return q;
}

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

	for (;;) {
		int n, m; cin >> n >> m;
		if (n == 0 && m == 0)break;
		if (n < 21) {
			int ans = 0;
			for (int j = 0; j < (1 << n); j++) dp[j] = 0;

			vector<string>v(1 << n);

			for (int i = 0, k = 1; i < n; i++, k *= 2) {
				string x; cin >> x;
				for (int j = k; j < (1 << n); j++) {
					if ((j&k) > 0) {
						if (v[j].length() != x.length()) v[j] = x;
						else {
							for (int l = 0; l < v[j].length(); l++) {
								if (v[j][l] != x[l]) v[j][l] = '1';
								else v[j][l] = '0';
							}
						}
					}
				}
			}
			string zero = "";
			for (int i = 0; i < m; i++) zero += "0";

			for (int j = 1; j < (1 << n); j++) {
				if (zero == v[j]) {
					ans = max(ans, countbit(j));
				}
			}
			cout << ans << "\n";
		}

		else {
			int ans = 0;
			for (int j = 0; j < (1 << m); j++) dp2[0][j] = dp2[1][j] = 0;
			for (int i = 0; i < n; i++) {
				string x; cin >> x;
				int sum = 0;
				int st = i % 2, bf = (i + 1) % 2;
				for (auto j : x) sum = sum * 2 + j - '0';
				dp2[st][sum] = 1;
				for (int j = 0; j < (1 << m); j++) {
					if (dp2[bf][j] != 0) dp2[st][j^sum] = max(dp2[st][j^sum], dp2[bf][j] + 1);
				}
				for (int j = 0; j < (1 << m); j++) {
					dp2[st][j] = max(dp2[st][j], dp2[bf][j]);
					dp2[bf][j] = 0;
				}
			}
			cout << dp2[(n-1)%2][0] << "\n";
		}
	}
}



Measured memory_bytes: 150220
A,B,C,X,Y = map(int,input().split())

if X>Y:
    A,B,X,Y = B,A,Y,X

if 2*C < B:
    print(C*2*Y)

elif 2*C < A + B:
    print(C*2*X+B*(Y-X))

else:
    print(A*X+B*Y)

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int a, b, k;
    cin >> a >> b >> k;
    for (int i = min(a, b); i >= 1; --i)
    {
        if (a % i == 0 && b % i == 0)
        {
            if (k == 1)
            {
                cout << i;
                return 0;
            }
            else
                --k;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    string s;
    cin >> a >> b >> s;
    bool ans = true;
    rep(i, 0, a + b + 1){
        if(i == a){
            if(s[i] != '-') ans = false;
        }else{
            if(!isdigit(s[i])) ans = false;
        }
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

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



Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        
        int N=sc.nextInt();
        int[] a=new int[N];
        
        int ans=0;
        
        
        for(int i=0;i<N;i++){
            a[i]=sc.nextInt();
            
        }
        for(int i = 0; i<N; i++) {
			while(a[i]%2 != 1) {
				ans++;
				a[i] /= 2;
			}
		}
        
        System.out.println(ans);
        
        
        
        
    }
}


Measured memory_bytes: 47984
#include <stdio.h>
int main(void) {
  int a,b,c;
  int i = 0;
  scanf("%d%d%d\n",&a,&b,&c);
  for(a;a<=b;a++){
    if(c%a == 0)i++;
  }
  printf("%d\n",i);
  return 0;
}



Measured memory_bytes: 2092
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

typedef long long LL;

int n, a[100];
LL memo[100][21];

LL dfs(int i, int sum) {
	LL res;
	if (i == n - 1) return sum == a[n - 1];
	if (! (sum >= 0 && sum <= 20)) return 0;
	if (memo[i][sum] > -1) return memo[i][sum];
	
	res = dfs(i + 1, sum + a[i]) + dfs(i + 1, sum - a[i]);
	return memo[i][sum] = res;
}

int main(void) {
	cin >> n;
	REP(i, n) scanf("%d", &a[i]);
	memset(memo, -1, sizeof(memo));
	cout << dfs(1,a[0]) << endl;
	return 0;
}

Measured memory_bytes: 1268
w, h, n = map(int, input().split())
xya = [list(map(int, input().split())) for _ in range(n)]
xya.sort(key=lambda x:x[2])

x = [0,w]
y = [0,h]
for i in range(len(xya)):
    if xya[i][2]==1:
        x[0] = max([x[0], xya[i][0]])
    elif xya[i][2]==2:
        x[1] = min([x[1],xya[i][0]])
    elif xya[i][2]==3:
        y[0] = max([y[0], xya[i][1]])
    else:
        y[1] = min([y[1], xya[i][1]])
if x[1]<x[0]:
    x[0]=x[1]
if y[1]<y[0]:
    y[0]=y[1]
print((x[1]-x[0])*(y[1]-y[0]))

Measured memory_bytes: 3064
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author TM
 */


#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <numeric>

#define SIZE 100005
#define MOD 1000000007

using namespace std;

class CKnotPuzzle {
public:
    void solve(std::istream &cin, std::ostream &cout) {
        long long int n, l;
        cin >> n >> l;
        vector<long long int> a_vec(n, 0);
        for (int j = 0; j < n; ++j) {
            cin >> a_vec[j];
        }
        int point = -1;
        for (int i = 0; i < n - 1; ++i) {
            if (a_vec[i] + a_vec[i + 1] >= l) {
                point = i;
            }
        }
        if (point == -1) cout << "Impossible" << endl;
        else {
            cout << "Possible" << endl;
            for (int i = 1; i <= point; ++i) {
                cout << i << endl;
            }
            for (int j = n - 1; j > point; --j) {
                cout << j << endl;
            }
        }
    }
};


int main() {
    CKnotPuzzle solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 1664
import sys
import numpy as np
import numba
from numba import jit

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from heapq import heappop,heappush,heapify

@jit
def main(n, a):
  for _ in range(1, n):
    x = heappop(a)
    y = heappop(a)
    heappush(a, (x + y)/2)
  return a[0]

n,*a = map(int,read().split())
heapify(a)
print(main(n,a))

Measured memory_bytes: 113808