akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
#define N 200001
#define ll long long
#define int ll 
#define pi pair<int , int>
#define pip pair<pair ,int>
#define mp make_pair 
#define f first
#define s second
#define mod 998244353
ll Mod(ll x, ll y, int p) 
{ll res = 1; x = x % p;
while (y > 0) 
{if(y & 1) res = (res*x) % p; 
y = y>>1;x = (x*x) % p; 
}return res; 
}
int* getlps(string pattern){
 int len = pattern.length();
 int * lps = new int[len];
 lps[0] = 0;
 int i = 1 , j = 0;
 while(i < len){
  if(pattern[i] == pattern[j]){
	  lps[i] = j+1;
   i++;
   j++;
  }
  else{
		if(j != 0){
		 j = lps[j-1];
		}
		else{
		 lps[i] = 0;
		 i++;
		}
  }
 }
 return lps;
}
class Triplet{
 public:
 int x ;
 int y ;
 int gcd;
};
Triplet extendedEuclid(int a , int b){
 if(b == 0){Triplet ans; ans.gcd = a;ans.x = 1;ans.y = 0;return ans;}
 Triplet smallAns = extendedEuclid(b , a%b);
 Triplet ans;
 ans.gcd = smallAns.gcd;
 ans.x = smallAns.y;
 ans.y = smallAns.x - (a/b)*smallAns.y;
 return ans;
}
int mmInverse(int a , int m){
 Triplet ans = extendedEuclid(a , m);
 return ans.x;
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int grid[3][3];
multiset<int> st;
for(int i = 0 ; i < 3 ; i++){
 for(int j = 0 ; j < 3 ; j++){
    cin>>grid[i][j];
 }
}
int n;
cin>>n;
int arr[n];
for(int i = 0 ; i < n ;i++){cin>>arr[i];st.insert(arr[i]);}
bool ok = true;
for(int i = 0 ; i < 3 ; i++){
  if(st.find(grid[i][i]) == st.end()){
      ok = false;
      break;
  }
}
if(ok){
 cout<<"Yes"<<endl;
 return 0;
}
ok = true;
for(int i = 0 ; i < 3 ; i++){
    if(st.find(grid[i][2-i]) == st.end()){
	  ok = false;
	  break;
	}
}
if(ok){
 cout<<"Yes"<<endl;
 return 0;
}
ok = true;
for(int i = 0 ; i < 3 ; i++){
	int j;
	for( j = 0 ; j < 3 ; j++){
	   if(st.find(grid[i][j]) == st.end()){
	     ok = false;
	     break;
	   }
	}
	if(j == 3){
	    cout<<"Yes"<<endl;
	    return 0;
	   }
	  // ok = true;
}
for(int i = 0 ; i < 3 ; i++){
	int j;
	for( j = 0 ; j < 3 ; j++){
	   if(st.find(grid[j][i]) == st.end()){
	     ok = false;
	     break;
	   }
	}
	//ok = true;
	if(j == 3){
	    cout<<"Yes"<<endl;
	    return 0;
	   }
}

 cout<<"No"<<endl;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    int n;
    cin>>n;
    vector<pair<int,int>> R(n),B(n);

    rep(i,n){
        int a,b;
        cin>>a>>b;
        R[i]={a,b};
    }
    rep(i,n){
        int c,d;
        cin>>c>>d;
        B[i]={c,d};
    }

    sort(all(B));
    int ans=0;
    vector<bool> ok(n,false);

    rep(i,n){
        int xb=B[i].first;
        int yb=B[i].second;
        int ind=-1,ma=-1;
        rep(j,n){
            if(ok[j]) continue;
            int xr=R[j].first;
            int yr=R[j].second;
            if(xr>=xb || yr>=yb) continue;
            if(ma<yr){
                ma=yr;
                ind=j;
            }
        }
        if(ind!=-1){
            //cout<<ind<<endl;
            ans++;
            ok[ind]=true;
        }
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n; std::cin >> n;
  auto count = [&] (int k) {
    int lb = 1;
    for (int i = 0; i < k - 1; i++) lb *= 10;
    int ub = lb * 10;
    if (ub <= n) return ub - lb;
    if (n < lb) return 0;
    return n - lb + 1;
  };
  int ans = 0;
  for (int k = 1; k <= 5; k += 2) {
    ans += count(k);
  }
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <cmath>
int main(){
    long long N;
    long long c3, c5, c15;
    long long sum3=0, sum5=0, sum15=0;
    std::cin >> N;
    c3 = N/3;
    c5 = N/5;
    c15 = N/15;
    if(c3>0){
        sum3 = c3*(3+3*c3)/2;
    }
    if(c5>0){
        sum5 = c5*(5+5*c5)/2;
    }
    if(c15>0){
        sum15 = c15*(15+15*c15)/2;
    }
    printf("%lld\n", N*(N+1)/2-(sum3+sum5-sum15));
    return 0;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb emplace_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
#define dupli(a) erase(unique(all(a)),a.end())
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
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;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}
int main(){
    ll a,b,c,d,e,f,g;cin>>a>>b>>c>>d>>e>>f>>g;
    string s,t;cin>>s>>t;
    if(a<=b)out("unsafe");
    else out("safe");
}

Measured memory_bytes: 3632
# 高さのリストを作成し、左から順に移動できるか検討する
# 移動できない場合は移動数の初期化（0にする）を行い、再度移動回数を計算
n = int(input())
h = list(map(int, input().split()))

move_list = []
move = 0

for i in range(n-1):
    if h[i] >= h[i+1]:
        move += 1
    else:
        move_list.append(move)
        move = 0

# 高さリストの最後も移動できた場合に移動回数を記憶    
move_list.append(move)

print(max(move_list))

Measured memory_bytes: 14252
package main

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

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

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

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

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

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func powInt(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

func sumInts(x []int) int {

	total := 0
	for _, v := range x {
		total += v
	}

	return total
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var S, T string

func main() {
	sc.Split(bufio.ScanWords)

	S, T = nextStr(), nextStr()
	if S == T {
		fmt.Println(0)
		return
	}

	ans := 0
	for i := 0; i < len(S); i++ {
		if S[i] != T[i] {
			ans++
		}

	}

	fmt.Println(ans)
}


Measured memory_bytes: 2804
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

int solve(int n, int r)
{
  if (n >= 10) {
    return r;
  } else {
    return r + 100 * (10 - n);
  }
}

int main()
{
  int n, r;
  std::cin >> n >> r;

  std::cout << std::setprecision(20);
  std::cout << solve(n, r) << std::endl;
}


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

using namespace std;

int main(void)
{
    string s;
    cin >> s;

    string ans = "";
    for(const auto& e : s)
    {
        if(e == 'B')
        {
            if(ans.size())
                ans.resize(ans.size() - 1);
        }
        else
        {
            ans += e;
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc124/tasks/abc124_c

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")

const int S_MAX = 1e5;

int N;
char S[S_MAX + 1];

int chg[2];

void solve() {
  N = strlen(S);
  REP(i, N) {
    int d = S[i] - '0';
    REP(j, 2) {
      chg[j] += i + j + d & 1;
    }
  }
  int ans = chg[0] > chg[1] ? chg[1] : chg[0];
  printf("%d\n", ans);
}

void input() {
  scanf("%s", S);
}

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


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  for(ll i=0;i<n;i++) {
    cin >> a[i];
  }
  ll m;
  cin >> m;
  vector<ll>q(m);
  vector<bool> ans(m);
  for(ll i=0;i<m;i++) {
    cin >> q[i];
  }
  for(ll i=0;i<(1<<n);i++) {
    bitset<20> b(i);
    ll tans=0;
    for(ll j=0;j<n;j++) {
      if(b.test(j)) {
        tans+=a[j];
      }
    } 
    for(ll j=0;j<m;j++) {
      if(tans==q[j]) {
        ans[j]=true;
      }
    }
  }
  for(ll i=0;i<m;i++) {
    if(ans[i]) {
      cout << "yes" << endl;
    }
    else {
      cout << "no" << endl;
    }
  }
}


Measured memory_bytes: 3104
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
#define Cin(T, x) T x; cin >> x
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cout(x) cout << (x) << "\n"
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) find(Range(c), x) != c.end()
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Vec2(T, vs, n, m) vector<vector<T>> vs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]

using namespace std;
using ll = long long;

int main(void){
    Cin(int, n);
    Cins(char, n, s);
    DeSort(s);
    Cout((s[0] == 'Y') ? "Four" : "Three");
}


Measured memory_bytes: 256
s1 = input()

n1 = list(s1)
c1 = 0
c2 = 0
for i1 in range(len(n1)):
    if i1 % 2 == 0:
        if n1[i1] == "1":
            c1 += 1
    else:
        if n1[i1] == "0":
            c1 += 1

for i2 in range(len(n1)):
    if i2 % 2 == 0:
        if n1[i2] == "0":
            c2 += 1
    else:
        if n1[i2] == "1":
            c2 += 1
print(min(c1, c2))

Measured memory_bytes: 3956
#include <stdio.h>
#include <stdlib.h>

#define MAX_K (100000L)

int main() {
  // read inputs
  long K, as[MAX_K];
  scanf("%ld", &K);
  for (long i = 0; i < K; i++) {
    scanf("%ld", &as[i]);
  }

  // ls[i] : The minimum possible value of ns[i],
  //         before considering the requirement that ns[i]
  //         must be a multiple of as[i]
  // us[i] : Similarly, the maximum possible of ns[i]
  long ls[MAX_K + 1] = {}, us[MAX_K + 1] = {};
  ls[K] = 2;
  us[K] = 2;
  for (long i = K - 1; i >= 0; i--) {
    // find ld and ud the minimum and maximum values in the range
    // [ls[i + 1], us[i + 1]] which are multiples of as[i]
    const long a = as[i], l = ls[i + 1], u = us[i + 1];
    const long ld = (l + a - 1) / a * a, ud = u / a * a;
    if (ld >= l && ld <= u && ud >= l && ud <= u) {
      ls[i] = ld;
      us[i] = ud + a - 1;
    } else {
      ls[0] = -1;
      us[0] = -1;
      break;
    }
  }
  if (ls[0] >= 0) {
    printf("%ld %ld\n", ls[0], us[0]);
  } else {
    printf("-1\n");
  }
}

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

#define ld			long double
#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define MOD         1000000007
#define sd(t) 		scanf("%d",&(t))
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define hii 		cout << "hii" << endl
#define okay 		cout << "okay" << endl
#define hey 		cout << "hey" << endl

template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; } 
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

clock_t time_p=clock();
void starboy1299()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}

const int N = 2e5+5;
int arr[105];
int dp[105][N];
int n, k, V;
int price[105];

int f(int idx, int rem){
	if(idx==n){
		if(rem==0) return 0;

		return 1e15;
	}

	if(dp[idx][rem]!=-1) return dp[idx][rem];

	int op1 = f(idx+1, rem);
	int op2 = (rem>=price[idx]) ? f(idx+1, rem-price[idx])+arr[idx] : 1e15;

	return dp[idx][rem] = min(op1, op2);
}

void solve()
{
	cin >> n >> k;
	memset(dp, -1, sizeof(dp));
	rep(i, 0, n){
		cin >> arr[i] >> price[i];
		V += price[i];
	}

	for(int i=V; i>=0; i--){
		if(f(0, i) <= k){
			cout << i << endl;
			return;
		}
	}
	
}			 	

int32_t main(){
	fast();
    int t = 1;
    // cin>> t;
    while(t--){
    	solve();
    }
	starboy1299();
}




Measured memory_bytes: 164352
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define PI 3.14159265359
#define MOD 1000000007
typedef long long LL;

template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

const int INF = 1 << 30;

int main(void) {
	string S;
	cin >> S;

	LL count = 0;
	LL top = 1;
	for (LL i = 0; i < S.size(); i++)
	{
		if (S[i] == 'W') {
			count += ((i + 1) - top);
			top++;
		}
	}
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 640
package main

import "fmt"

func main() {
        var n int
        fmt.Scan(&n)
        maxF := n / 4
        maxS := n / 7
        exists := false
        for i := 0; i <= maxF; i++ {
                for k := 0; k <= maxS; k++ {
                        if n == 4*i+7*k {
                                exists = true
                                break
                        }
                }
        }
        if exists {
                fmt.Println("Yes")
        } else {
                fmt.Println("No")
        }
}

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

using namespace std;

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi vector<int>
#define vvi vector<vector<int> >
#define vpi vector<pi >
#define pi pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define all(n) n.begin(), n.end()

#define FROMTO(var, from, to) for (register int var = (from), var##down = ((int)(to)) < ((int)(from));var##down ? (var >= (int)(to)) : (var <= (int)(to));var##down ? var-- : var++)
#define UPTO(var, from, to)   for (register int var = (from); var <= ((int)to); var++)
#define DOWNTO(var, from, to) for (register int var = (from); var >= ((int)to); var--)
#define FOR(var, to)          UPTO(var, 0, (to)-1)
#define DOWN(var, from)       DOWNTO(var, (from)-1, 0) 

#define INIT(var, val) FOR(i,countof(var)) var[i] = val
#define INPUT(var) FOR(i,countof(var)) cin >> var[i]
#define INPUT1(var) FOR(i,countof(var)) cin >> var[i], var[i]--

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)
#define QSORT(v,b) qsort(v,countof(v),sizeof(*v),b)

#define MOD 1000000007
#define INF ((1 << 30)-1)
#define LINF ((1LL << 62)-1)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

struct Comb {
    vector<vector<s64> > data;
    Comb(int n) { // O(n^2)
        data = vector<vector<s64> >(n+1,vector<s64>(n+1,1));
        UPTO(i,1,n) {
            FOR(j,i+1) {
                if (!j || j == i) data[i][j] = 1;
                else data[i][j] = data[i-1][j-1] + data[i-1][j];
            }
        }
    }
    
    s64 ncr(int n, int r) {
        return data[n][r];
    }
};

static inline int ri() {
  int a;
  scanf("%d", &a);
  return a;
}

int int_less(const void *a, const void *b) {
  return (*((const int*)a) - *((const int*)b));
}
int int_greater(const void *a, const void *b) {
  return (*((const int*)b) - *((const int*)a));
}

int main() {
    int a = ri();
	int b = ri();
	int k = ri();
	set<int> s;
	UPTO(i,a,min(b,a+k-1)) s.insert(i);
	DOWNTO(i,b,max(b-k+1,a)) s.insert(i);
	for (auto i : s) cout << i << endl;
    return 0;
}


Measured memory_bytes: 256
count = range(1000001) 
for i in xrange(2, 500001):
    n = i * 2
    while n <= 1000000:
        count[n] -= (count[i] - 1) 
        n += i

ret = [0] * 1000001
ret[1] = 2
for i in xrange(2,1000001):
    ret[i] += count[i] + ret[i-1] - 1

t = int(raw_input())
for i in xrange(t):
    print ret[int(raw_input())] 

Measured memory_bytes: 67744
(function() {
    'use strict';

    var fs = require('fs');
    var contents = fs.readFileSync('/dev/stdin', 'utf-8');

    var minMaxSum = function(contents) {
        var lines = contents.trim().split("\n");
        var n = parseInt(lines[0].trim());

        var chars = lines[1].trim().split(" ");
        var min = 1000000;
        var max = -1000000;
        var sum = 0;
        for (var i = 0; i < chars.length; i++) {
            var a = parseInt(chars[i]);
            if (a > max) {
                max = a;
            }
            if (a < min) {
                min = a;
            }
            sum += a;
        }
        console.log(min + " " + max + " " + sum);
    }

    minMaxSum(contents);
})();

Measured memory_bytes: 16848
using namespace std;

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <limits>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <numeric>
typedef long long ll;
typedef pair<int,int> p;

int main()
{
  int n;
  cin >> n;
  vector<p> red(n,{0,0});
  vector<p> blue(n,{0,0});
  int tmp1,tmp2;
  for (int i = 0; i < n; i++){
    cin >> tmp1 >> tmp2;
    p tmp = make_pair(tmp2, tmp1);
    red[i] = tmp;
  }
  for (int i = 0; i < n; i++){
    cin >> tmp1 >> tmp2;
    p tmp = make_pair(tmp1, tmp2);
    blue[i] = tmp;
  }

  sort(red.begin(), red.end());
  sort(blue.begin(), blue.end());



  int res = 0;
  for (int b = 0; b < n; b++){
    for (int r = n-1; r >= 0; r--){
      if (blue[b].first > red[r].second) {
        if (blue[b].second > red[r].first) {
          res++;
          red.erase(red.begin() + r);
          blue.erase(blue.begin() + b);
          n--;
          b--;
          break;
        }
      }
    }
  }

  cout << res << endl;
  return 0;
}


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

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

#define fr first
#define sc second

int main(){
	static ll n;
	static ll a[200010];
	scanf("%lld",&n);
	for(int i=0;i<n;i++){
		scanf("%lld",&a[i]);
	}
	
	vector<ll> vec;
	for(int i=0;i<n;i++){
		vec.push_back(a[i]-i-1);
	}
	sort(vec.begin(),vec.end());
	
	ll ret=0;
	for(int i=0;i<vec.size();i++){
		ret+=abs(vec[i]-vec[n/2]);
	}
	cout<<ret<<endl;
}



Measured memory_bytes: 3956
s = gets.chomp.reverse
choice = ["dream", "dreamer", "erase", "eraser"].map(&:reverse)
while !s.empty?
    flag = false
    choice.each do |i|
        len = i.size
        if s[0, len] == i
            s = s[len, s.size]
            flag = true
        end
    end
    if !flag
        puts "NO"
        exit
    end
end

puts "YES"

Measured memory_bytes: 4988
import sys

sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline

""" Input
S = input().rstrip()
N = int(input())
A = list(map(int, input().split()))
A = np.array(input().split(), dtype=np.float64)
D = [int(input()) for _ in range(N)]
AB = [[int(x) for x in input().split()] for _ in range(N)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]
"""
import numpy as np

A, B, H, M = map(int, input().split())

l_pos = 6 * M
s_pos = 30 * H + 0.5 * M

deg = s_pos - l_pos

sa = np.sqrt(A ** 2 + B ** 2 - 2 * A * B * np.cos(np.deg2rad(deg)))
print(sa)


Measured memory_bytes: 27200
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int main() {
  int N,M;
  cin >> N >> M;
  vector<int> H(N+1);
  vector<int> mx(N+1,0);
  vector<int> A(M);
  vector<int> B(M);
  rep(i,N){
    cin >> H[i+1];
  }
  rep(i,M){
    cin >> A[i];
    cin >> B[i];
    mx[A[i]] = max(mx[A[i]], H[B[i]]);
    mx[B[i]] = max(mx[B[i]], H[A[i]]);
  }
  int res = 0;
  rep(i,N){
    if(H[i+1] > mx[i+1]) res++;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 4816
#include<bits/stdc++.h>
#include<stdlib.h>
#include<string.h>
#define ll long long
#define T int test; scanf("%d",&test); while(test--)
#define pb push_back
#define in insert
#define sc(n) scanf("%d",&n)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define lsc(n) scanf("%lld",&n)
#define lsc2(a,b) scanf("%lld%lld",&a,&b)
#define rep(i,n) for(i=0;i<n;i++)
#define fr(i,a,b) for(i=a;i<=b;i++)
#define gcd(a,b) __gcd(a,b)
#define gcd3(a,b,c) __gcd(__gcd(a,b),c)
#define lcm(a,b) (a*b)/__gcd(a,b)
using namespace std;


int main()
{
	int w,s;
	sc2(s,w);
	if(w>=s)
	{
		cout << "unsafe\n";
	}
	else
	{
		cout << "safe\n";
	}
    return 0;
}


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

using namespace std;

const int N = 410;

int main() {
  int n; cin >> n;
  int k; cin >> k;
  int q; cin >> q;
  vector <int> player(n + 1, 0);
  int loss = 0;
  while(q--) {
    int a; cin >> a;
    loss++; player[a]++;
  }
  for(int i = 1; i <= n; i++) {
    int total = (k - loss + player[i]);
    if(total > 0) {
      puts("Yes");
    }
    else {
      puts("No");
    }
  }
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <cmath>
using namespace std;

int main()
{
    string S;
    int n1 = 0, n0 = 0;

    cin >> S;

    for (int i = 0; i < S.size(); i++) {
        if (S[i] == '0') n0++;
        else n1++;
    }

    cout << 2*min(n1, n0) << endl;
    
    return 0;
}

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

#define endl '\n'
#define int ll
using namespace std;
typedef long long ll;

const int N = 3003;

string s, t;
ll dp[N][N];

void init();
void process();

int32_t main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    init();
    process();
    cout.flush();
    return 0;
}

void init()
{
    cin >> s >> t;
}

void process()
{
    for(size_t i = 1; i <= s.size(); i++)
        for(size_t j = 1; j <= t.size(); j++)
        {
            if(s[i-1] == t[j-1]) dp[i][j] = dp[i-1][j-1]+1;
            dp[i][j] = max({ dp[i][j], dp[i-1][j], dp[i][j-1] });
        }
    stack<char> stk;
    for(size_t i = s.size(), j = t.size(); i > 0 && j > 0;)
    {
        if(s[i-1] == t[j-1]) 
        {
            stk.push(s[i-1]); i--, j--;
        }
        else if(dp[i-1][j] > dp[i][j-1]) i--;
        else j--;
    }
    while(!stk.empty()) cout << stk.top(), stk.pop();
    cout << endl;
}



Measured memory_bytes: 70656
import string
from collections import Counter


def count(s):
    """Count the occurence of each alphabet chars.
    The count is done case insensitively.

    >>> count('A:a b')  # doctest: +NORMALIZE_WHITESPACE
    Counter({'a': 2, 'b': 1})
    """
    return Counter([c for c in s.lower() if c.isalpha()])


def run():
    s = ''
    while True:
        try:
            s += input()
        except EOFError:
            break

    c = count(s)
    for a in string.ascii_lowercase:
        print(a, ':', c[a])


if __name__ == '__main__':
    run()



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

#define INF (1LL << 31 - 1)
#define MOD int(1e9+7)
#define repi(i,j,n) for(int i = (j); i < (n); ++i)
#define rep(i,n) repi(i,0,n)
#define fi first
#define se second

inline void init() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

bool check(string s) {
    int size_ = s.size();
    for (int i = 0; i < size_ - 1; ++i) {
        if (s[i] != s[i + 1]) return false;
    }
    return true;
}

string s;
int ans = (1LL << 31 - 1), si;
map<char, bool> mp;

int main() {
    cin >> s;

    si = s.size();
    for (int i = 0; i < si; ++i) mp[s[i]] = true;

    for (int i = 0; i < 26; ++i) {
        char c = 'a' + i;
        string t = s, u = "";
        int tmp = 0, n = si;
        if (!mp[c]) continue;

        while (!check(t)) {
            if (n < 0) break;
            tmp++;
            for (int j = 0; j < n - 1; ++j) {
                if (t[j] == c or t[j + 1] == c) {
                    u += c;
                }
                else {
                    u += t[j];
                }
            }
            t = u;
            u = "";
            n--;
        }
        ans = min(ans, tmp);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<numeric>
#include<cstdint>

int const MAXN = 2e5;

int64_t H[MAXN], N, K;

int main() {
  std::cin >>  N >> K;
  for(int i = 0; i < N; ++i) std::cin >> H[i];
  std::sort(H, H+N);
  int64_t ans = std::accumulate(H, H+std::max((int64_t)0, N-K), (int64_t)0);
  std::cout << ans << std::endl;
  return 0;
}



Measured memory_bytes: 1792
#include<cstdio>
#include<cstring>
char s[100005],t[100005];
int a,b,c,q,d,ns[100005],nt[100005];
int main(){
    scanf("%s%s%d",s,t,&q);
    int ls=strlen(s),lt=strlen(t);
    for(int i=0;i<ls;++i){
    	if(s[i]=='A') ns[i+1]=ns[i]+1;
    	else ns[i+1]=ns[i]+2;
    }
    for(int i=0;i<lt;++i){
    	if(t[i]=='A') nt[i+1]=nt[i]+1;
    	else nt[i+1]=nt[i]+2;
    }
    for(int i=1;i<=q;++i){
        scanf("%d%d%d%d",&a,&b,&c,&d);
        if((ns[b]-ns[a-1])%3==(nt[d]-nt[c-1])%3) puts("YES");
        else puts("NO");
    }
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int A, B, C;
  cin >> A >> B >> C;
  bool ok = false;
  if (A == B && B == C) {
  }
  else if (A == B | B == C | A == C) {
    ok = true;
  }
  if (ok) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
    
}

Measured memory_bytes: 3608
n, m, k = map( int, input().split() )
p = 998244353

fact = [ 1, 1 ]       # fact[k] = k!
inv = [ 0, 1 ]        # inv[k] = k^(-1)
fact_inv = [ 1, 1 ]   # fact_inv[k] = (k!)^(-1)
powm_1 = [ 1, m-1 ]
for a in range( 2, 2 * ( 10 ** 5 ) + 1 ):
    fact.append( a * fact[-1] % p )
    inv.append( - inv[p%a] * (p//a) % p )
    fact_inv.append( fact_inv[-1] * inv[a] % p )
    powm_1.append( powm_1[-1] * (m-1) % p )

ans = 0
for i in range( k + 1 ):
    ans = ( ans + m * powm_1[n-1-i] * fact[n-1] * fact_inv[n-1-i] * fact_inv[i] ) % p

print( ans )

Measured memory_bytes: 40848
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
char s[100001],s2[100001],s3[100001];
int leth(char *ch) 
{
	int i=0;
	for(i=0;ch[i];i++) ;
	return i;
}
int main(){
	cin>>s;
	int flag=1,len=leth(s);
	for(int i=len-1;i>=0;i--){
	    int L=i,R=len-i-1; 
		if (L>R)
		break;
		if(s[L]==s[R])
		flag=0;
		else 
		{
			flag=1;
			break;
		}
	}
	if(!flag)
	{
		cout<<"Yes"<<endl;
		return 0;
	}
	int cnt=0;
	for(int i=0;i<len;i++)
		s2[i]=s[i];
	for(int i=0;i<len;i++){
		if(s2[i]=='b')
		s2[i]='d';
		else if(s2[i]=='d')
		s2[i]='b';
		else if(s2[i]=='p')
		s2[i]='q';
		else if(s2[i]=='q')
		s2[i]='p';
		if(s2[i]==s[i])
		 cnt=1;
		 else
		 	{
		 		cnt=0;
		 		break;
			 }
	}
	if(cnt==1)
	{
		cout<<"Yes"<<endl;
		return 0; 
	}
	
	for(int i=0;i<len;i++)
		s2[len-i-1]=s[i];
		
		for(int i=len-1;i>=0;i--){
	    if(s2[len-i-1]==s[len-i-1])
		 flag=0;
		else 
		{
			flag=1;
			break;
		}
	}
	if(!flag)
	{
		cout<<"Yes"<<endl;
		return 0;
	}
	for(int i=0;i<len;i++){
		if(s2[len-i-1]=='b')
		s2[len-i-1]='d';
		else if(s2[len-i-1]=='d')
		s2[len-i-1]='b';
		else if(s2[len-i-1]=='p')
		s2[len-i-1]='q';
		else if(s2[len-i-1]=='q')
		s2[len-i-1]='p';
		if(s2[len-i-1]==s[len-i-1])
		 cnt=1;
		 else
		 	{
		 		cnt=0;
		 		break;
			 }
	}
	if(cnt==1)
	{
		cout<<"Yes"<<endl;
		return 0; 
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <unordered_set>
#include <queue>
#include <cmath>
 
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, n, m) for(int i=n; i<m; ++i)

using Graph = vector<vector<int>>;

// 深さ優先探索
vector<bool> seen;
void dfs(const Graph &G, int v) {
    seen[v] = true; // v を訪問済にする

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue; // next_v が探索済だったらスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main() {
  ll L,R,d;
  cin >> L >> R >> d;
  
  ll cnt = 0;
  FOR(i, L, R+1){
    if(i%d==0) cnt++;
  }
  
  cout << cnt << endl;
  
  
}

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

int main() {
    int A[5][4][11], n;
    for(int i = 0; i < 5; i++)
        for(int j = 0; j < 4; j++)
            for(int k = 0; k < 11; k++)A[i][j][k] = 0;

    cin >> n;
    for(int i = 0; i < n; i++) {
        int b, f, r, v;
        cin >> b >> f >> r >> v;
        A[b][f][r] += v;
    }

    for(int b = 1; b <= 4; b++) {
        if(b > 1) cout << "####################\n";
        for(int f = 1; f <= 3; f++){
            for(int r = 1; r <= 10; r++){
                cout << " " << A[b][f][r];
            }
            cout << endl;
        }
    }

    return 0;
}


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

int main()
{
  ll n,a[1005];
  cin>>n;
  ll a1=0;
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
    if(i%2==0 && a[i]%2==1)
      a1++;
  }

  cout<<a1<<"\n";
  return 0;
}

Measured memory_bytes: 3640
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<cstring>
#include<vector>
#include<set>
#define LL long long
using namespace std;
int n,m;
int a[123][123];

int main()
{
  int i,j;
  scanf("%d%d",&n,&m);
  if(!n)
    {
	  printf("1 1\n#\n");
	}
  else if(!m)
    {
	  printf("1 1\n.\n");
	}
  else
    {
	  n--,m--;
	  for(i=51;i<=100;i++)
	    for(j=1;j<=100;j++) a[i][j]=1;
	  for(i=2; ;i+=3)
	    {
	     if(!m) break;
		  for(j=1;j<=99;j++)
		    {
			  if(!m) break;
			  m--,a[i+(j&1)][j]=1;
			}
		}
	  for(i=99; ;i-=3)
	    {
	     if(!n) break;
		  for(j=1;j<=99;j++)
		    {
			  if(!n) break;
			  n--,a[i-(j&1)][j]=0;
			}
		}
	  printf("100 100\n");
	  for(i=1;i<=100;i++)
	    {
		  for(j=1;j<=100;j++) 
		    if(!a[i][j]) printf(".");
		    else printf("#");
		  printf("\n");
		}
	}
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    unsigned int x, y;
    cin >> x >> y;
    bitset<32> bit(x), bit1(y);
    cout << (bit&bit1) << endl;
    cout << (bit|bit1) << endl;
    cout << (bit^bit1) << endl;
}


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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();


    int n;
    string s;
    cin>> n>> s;

    if(n &1)
    {
        cout << "No\n";
        return 0;
    }

    cout<<  ( s.substr (0, n/2) == s.substr (n/2, n/2) ? "Yes\n" : "No\n");

    return 0;
}




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

int main() {
  int n, ans = 0, tmp = 0;
  string s;
  cin >> n >> s;
  
  for (char c : s) {
    if (c == 'I') {
      tmp++;
    } else if (c == 'D') {
      tmp--;
    }
    if (tmp > ans) {
      ans = tmp;
    }
  }
  cout << ans << endl;
}

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

string ex(long long int a){
	string s="000000000000000000000000000000";
	for(int i=0;i<30;i++){
		if(a&1<<i){
			s[29-i]='1';
		}
	}
	
	//cout<<s<<endl;
	
	return s;
}

int main(){
	long long int n,k;
	cin>>n>>k;
	
	string s1;
	s1=ex(k);
	string s2="000000000000000000000000000000";
	string s3="000000000000000000000000000000";
	
	
	long long int cnt=0;
	for(int i=0;i<30;i++){
		if(cnt==0&&s1[i]=='1'){
			cnt++;
		}else if(cnt==1){
			s3[i]='1';
		}
	}
	
	//cout<<s1<<endl;
	//cout<<s2<<endl;
	//cout<<s3<<endl;
	
	
	long long int ans1=0;
	long long int ans2=0;
	long long int ans3=0;
	
	long long int ans=0;
	
	vector<string> a(n);
	vector<long long int> b(n);
	int flag;
	for(int i=0;i<n;i++){
		long long int x;
		cin>>x>>b[i];
		a[i]=ex(x);
		
		flag=0;
		for(int j=0;j<30;j++){
			if(s1[j]=='0'&&a[i][j]=='1'){
				flag=1;
				break;
			}
		}
		if(flag==0)ans1+=b[i];
		
		/*
		for(int l=0;l<15;l++){
			s2="000000000000000000000000000000";
			int cnt=0;
			for(int m=0;m<30;m++){
				if(cnt<=l&&s1[m]=='1'){
					cnt++;
					s2[m]='1';
				}else if(cnt==l+1&&s1[m]=='1'){
					cnt++;
				}else if(cnt>l+1){
					s2[m]='1';
				}
			}
			
			//cout<<s2<<endl;
			
			ans2=0;
			flag=0;
			for(int j=0;j<30;j++){
				if(s2[j]=='0'&&a[i][j]=='1'){
					flag=1;
					break;
				}
			}
			if(flag==0)ans2+=b[i];
			ans=max(ans,ans2);
		}
		
		*/
		
		
		flag=0;
		for(int j=0;j<30;j++){
			if(s3[j]=='0'&&a[i][j]=='1'){
				flag=1;
				break;
			}
		}
		if(flag==0)ans3+=b[i];
	}
	
	for(int l=0;l<30;l++){
		s2="000000000000000000000000000000";
		int cnt=0;
		for(int m=0;m<30;m++){
			if(cnt<=l&&s1[m]=='1'){
				cnt++;
				s2[m]='1';
			}else if(cnt==l+1&&s1[m]=='1'){
				cnt++;
			}else if(cnt>l+1){
				s2[m]='1';
			}
		}
		//cout<<s2<<endl;
		ans2=0;
		for(int i=0;i<n;i++){
			//cout<<s2<<endl;
			
			flag=0;
			for(int j=0;j<30;j++){
				if(s2[j]=='0'&&a[i][j]=='1'){
					flag=1;
					break;
				}
			}
			if(flag==0)ans2+=b[i];
		}
		//cout<<ans2<<endl;
		ans=max(ans,ans2);
	}
	
	ans=max(ans1,max(ans,ans3));
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 8064
import scala.io.StdIn.readInt

object Main extends App {
  val a = readInt
  val b = readInt
  val c = readInt
  val d = readInt
  val p = readInt
  val x = a*p
  val y = if(p<=c) b else b+d*(p-c)
  val z = if(x>y) y else x
  println(z)
}

Measured memory_bytes: 43792
import java.util.*;

public class Main {
  public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int x = sc.nextInt();
    int count = 0;
    for(int i = 0; i < a + 1; i++) {
      for(int j = 0; j < b + 1; j++) {
        for(int k = 0; k < c + 1; k++) {
          if(500 * i + 100 * j + 50 * k == x) {
            count++;
          }
        }
      }
    }
    System.out.println(count);
  }
}


Measured memory_bytes: 21204
#include <iostream>
#include <vector>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v, n) sort(v, v+n)
#define print(x) cout << x << endl;

using namespace std;


int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N, K, D;
    cin >> N >> K;
  	
  	vector<int> S = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
  	
  	
    REP(i, N){
      	cin >> D;
        REP(j, S.size()){
          if(S[j] == D){
          	S.erase(S.begin() + j);
            break;
          }
      	}
    }
  	
  	int keta;
  	keta = to_string(N).length();
  
  	vector<int> L = {0};
  	vector<int> M;
  	string tmp;
  	int k = 0;
  	while(k < keta){
      M = {};
      REP(j, L.size()){
        REP(i, S.size()){
            tmp = to_string(L[j]) + to_string(S[i]);
            M.push_back(stoi(tmp));
        }
      }
      L = M;
      k += 1;
    }
  	M = {};
    REP(j, L.size()){
		REP(i, S.size()){
            tmp = to_string(L[j]) + to_string(S[i]);
            M.push_back(stoi(tmp));
        }
    }
  	REP(i, M.size()){
		L.push_back(M[i]);
    }
  
  	REP(j, L.size()){
      	if(L[j] >= N){
          	print(L[j]);
         	return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 1092
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

// fact(n)
int fact(int n){
	if(n == 1)	return 1;
	else return (n * fact(n - 1));
}

// nCr(n,r)
int nCr(int n, int r){
	if(r == 0 || r == n)	return 1;
	else if(r == 1)	return n;
	return (nCr(n - 1, r - 1) + nCr(n - 1, r));
}

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

// lcm(a.b)
int lcm(int a,int b){
	return (a * b) / gcd(a,b);
}

// qsort(array, size, sizeof(int),comp);
int comp(const int *a,const int *b){
	return (*a - *b);
}

// append(array,*size,addNum)
void append(int *array,int *size,int num){
	realloc(array, sizeof(int) * (*size + 1));
	array[(*size)] = num;
	++(*size);
}

// pop(array,*size) & nongetpop(array,*size)
int pop(int *array,int *size){
	int temp = array[(*size - 1)];
	nongetpop(array,&(*size));
	return temp;
}

int nongetpop(int *array,int *size){
	realloc(array,sizeof(int) * (*size - 1));
	--(*size);
}

int main(int argc, char const *argv[])
{
	int a,b,c,x;
	int cnt = 0;
	scanf("%d %d %d %d",&a,&b,&c,&x);
	for (int i = 0; i <= a; ++i)
	{
		for (int j = 0; j <= b; ++j)
		{
			for (int k = 0; k <= c; ++k)
			{
				if((500 * i + 100 * j + 50 * k) == x)	++cnt;
			}
		}
	}
	printf("%d\n", cnt);
	return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }

    class Program
    {
        static void Main(string[] args) => B();

        static void B()
        {
            var NMC = ReadSplitInt();
            var B = ReadSplitInt();
            var ans = 0;
            for (var i = 0; i < NMC[0]; i++)
            {
                var A = ReadSplitInt();
                if (Range(0, B.Count).Select(x => A[x] * B[x]).Sum() + NMC[2] > 0)
                    ans++;
            }
            Console.WriteLine(ans);
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int DigitsSum(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static IList<string> ReadSplit() => Read().Split().ToList();
        static IList<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
    }
}

Measured memory_bytes: 13396
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<iostream>
using namespace std;

struct Node {
    int key;
    Node *right, *left, *parent;
};

Node *root, *NIL;

Node * find(Node *u, int k) {
    while (u != NIL && k != u->key) {
        if (k < u->key) u = u->left;
        else u = u->right;
    }
    return u;
}

void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;
    
    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;
    
    while (x != NIL) {
        y = x;
        if (z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }
    
    z->parent = y;
    if (y == NIL) {
        root = z;
    } else {
        if (z->key < y->key) {
            y->left = z;
        } else {
            y->right = z;
        }
    }
}

void inorder(Node *u) {
    if (u == NIL) return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}
void preorder(Node *u) {
    if (u == NIL) return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

int main() {
    int n, i, x;
    string com;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) {
        cin >> com;
        if (com[0] == 'f') {
            scanf("%d", &x);
            Node *t = find(root, x);
            if (t != NIL) printf("yes\n");
            else printf("no\n");
        } else if (com == "insert") {
            scanf("%d", &x);
            insert(x);
        } else if (com == "print") {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }
    
    return 0;
}


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

int main(){
    ll n,a,q,b,c,sum=0;
    cin>>n;
    ll cnt[100001]={};
    rep(i,n){
        cin>>a;
        cnt[a]++;
        sum+=a;
    }
    cin>>q;
    rep(i,q){
        cin>>b>>c;
        sum-=b*cnt[b];
        sum+=c*cnt[b];
        cnt[c]+=cnt[b];
        cnt[b]=0;
        cout<<sum<<endl;
    }
    return 0;
}

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

int main() {
    int X,Y,Z;
    cin>>X>>Y>>Z;
    int human=0;
    X-=2*Z;
    while(1){
        if(X-Y>=0){
            human+=1;
            X-=Y;
        }else{
            cout<<human<<endl;
            return 0;
        }
        if(X-Z>=0){
            X-=Z;
        }else{
            cout<<human<<endl;
            return 0;
        }
    }
return 0;}
/*
g++ code.cpp
./a.out
*/

Measured memory_bytes: 256