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

int main(){
    int a,b;
    cin >> a >> b;
    if(a>=13)cout << b << endl;
    if(a >= 6 && a <= 12)cout << b/2 << endl;
    if(a <= 5)cout << 0 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
const long long INF = 1e18;
const double PI = 2 * asin(1);
typedef long long ll;


int main(){

  int H, W, K; cin >> H >> W >> K;
  char S[H][W]; int ans[H][W];
  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++){
      cin >> S[i][j];
      ans[i][j] = 0;
    }
  }

  int cnt = 0;
  for (int i = 0; i < H; i++){
    bool flag = false;
    for (int j = 0; j < W; j++){
       if (flag == false && S[i][j] == '#'){
         flag = true;
         cnt++;
         ans[i][j] = cnt;
       }else if(flag == true){
         if (S[i][j] == '#'){
           cnt++;
         }
         ans[i][j] = cnt;
       }
    }
  }

  for (int i = H - 1; i >= 0; i--){
    for (int j = W - 2; j >= 0; j--){
      if (ans[i][j] == 0){
        ans[i][j] = ans[i][j + 1];
      }
    }
  }

  for (int i = H - 2; i >= 0; i--){
    for (int j = 0; j < W; j++){
      if (ans[i][j] == 0){
        ans[i][j] = ans[i + 1][j];
      }
    }
  }

  for (int i = 1; i < H; i++){
    for (int j = 0; j < W; j++){
      if (ans[i][j] == 0){
        ans[i][j] = ans[i - 1][j];
      }
    }
  }
  
  

  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++){
      cout << ans[i][j];
      if (j != W - 1) cout << " " ;
    }
    cout << endl;
  }
  
  
  
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  
  vector<int> x(n), y(n), h(n);
  for(int i = 0; i < n; i++){
    cin >> x.at(i) >> y.at(i) >> h.at(i);
  }
  
  bool flag = false;
  for(int i = 0; i <= 100; i++){
    for(int j = 0; j <= 100; j++){
      bool judge = true;
      int height;
      for(int k = 0; k < n; k++){
        if(h.at(k) != 0){
          height = h.at(k) + abs(x.at(k) - i) + abs(y.at(k) - j);
          break;
        }
      }
      for(int k = 0; k < n; k++){
        if(h.at(k) != max(height - abs(x.at(k) - i) - abs(y.at(k) - j), 0)){
          judge = false;
          break;
        }
      }
      if(judge){
          cout << i << " " << j << " " << height << endl;
          flag = true;
          break;
      }
      if(flag) break;
    }
    if(flag) break;
  }
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> vec(N);
  for(int i = 0; i < N; ++i){
    cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  
  int Alice = 0, Bob = 0;
  for (int i = 0; i < vec.size(); ++i){
  	if (0 == (i&1)) Alice += vec.at(i);
    else			Bob += vec.at(i);
  }
  cout << Alice - Bob << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,A,B;
  cin >> N >> A >> B;
  int ans = 0;
  for(int i = 1; i < N+1; i++){
    int value = i;
    int sum = 0;
    while(value!=0){
      sum += value%10;
      value /= 10;
    }
    if(sum >= A && sum <= B){
      ans += i;
    }
  }
  cout << ans << endl;
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;
typedef vector<int> vint;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int a, b, c;
  cin >> a >> b >> c;
  cout << (a <= c && c <= b ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int n;

int main() {
	cin >> n;
	
	int ans = -1;
	incII(i, 0, n) {
		if(i * 108 / 100 == n) { ans = i; }
	}
	
	if(ans == -1) { cout << ":(" << endl; } else { cout << ans << endl; }
	
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int pasta, juice;
    int mini[2] = {3000, 3000};
    int i;
    
    for (i = 0; i < 3; i++){
        scanf("%d", &pasta);
        if (mini[0] > pasta) mini[0] = pasta;
    }
    for (i = 0; i < 2; i++){
        scanf("%d", &juice);
        if (mini[1] > juice) mini[1] = juice;
    }
    printf("%d\n", mini[0] + mini[1] - 50);
    
    return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
#define R register int
#define G if(++ip==ie)if(fread(ip=buf,1,SZ,stdin))
using namespace std;
const int SZ=1<<19,N=1e5+9,M=2*N;
char buf[SZ],*ie=buf+SZ,*ip=ie-1;
inline int in(){
    G;while(*ip<'-')G;
    R x=*ip&15;G;
    while(*ip>'-'){x*=10;x+=*ip&15;G;}
    return x;
}
int he[N],ne[M],to[M],f[N],a[N],b[N];
int Getf(R x){
    return x==f[x]?x:f[x]=Getf(f[x]);
}
void Dfs(R x,R op){
    a[x]=op;
    for(R y,i=he[x];i;i=ne[i])
        if((y=to[i])!=f[x])
            f[y]=x,Dfs(y,-op),a[x]+=a[y];
}
int main(){
    R n=in(),m=in(),rt=1,re=1,p=0,ans=0;
    for(R i=1;i<=n;++i)f[i]=i;
    for(R p=0,i=1;i<=m;++i){
        R x=in(),y=in();
        if(Getf(x)!=Getf(y))f[f[x]]=f[y];
        else{rt=x,re=y;continue;}//把多的边单独拿出来
        ne[++p]=he[x];to[he[x]=p]=y;
        ne[++p]=he[y];to[he[y]=p]=x;
    }
    f[rt]=0;Dfs(rt,1);
    if(n==m){//基环树
        for(R x=re;x;x=f[x])b[++p]=a[x];
        if(p&1){//奇环
            if(a[rt]&1)return puts("-1"),0;
            for(R x=re;x;x=f[x])a[x]-=a[rt]>>1;
        }
        else{//偶环
            if(a[rt])return puts("-1"),0;
            sort(b+1,b+p+1);
            for(R x=re;x;x=f[x])a[x]-=b[p>>1];
        }
    }//树
    else if(a[rt])return puts("-1"),0;
    for(R i=1;i<=n;++i)ans+=abs(a[i]);
    return cout<<ans<<endl,0;
}


Measured memory_bytes: 8576
// ----- In the name of ALLAH, the Most Gracious, the Most Merciful -----

#include<bits/stdc++.h>
using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define deb(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define memo(a,val) memset(a,val,sizeof(a))
#define NINJA ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(a) a.begin(),a.end()
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;i<n;i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define dloop(i,n) for(int i=n-1;i>=0;i--)
#define iii tuple<int,int,int>
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define int long long
#define ld long double
#define pb push_back
#define endl "\n"
#define setbits __builtin_popcountll
#define mp map<int,int>
#define F first
#define S second
#define sz(v) (int)v.size()
#define mod 1000000007
#define inf (int)1e18

const int mxn = 2e5+10;
int pref[mxn];
int suf[mxn];
int a[mxn];

int32_t main(){
	NINJA;

	int n; cin >> n;

	for1(i,n) cin >> a[i];

	for1(i,n) pref[i] = pref[i-1] + a[i];

	for(int i=n;i>=1;i--) suf[i] = (suf[i+1] + a[i])%mod;

	int tot = 0;

	for1(i,n-1){
		tot = (tot + (a[i]*(suf[i+1])%mod))%mod;
	}

	cout << tot << endl;
	
	return 0;
}


Measured memory_bytes: 8280
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <map>

std::vector<intmax_t> divisor(intmax_t n) {
  std::vector<intmax_t> res;
  for (intmax_t i = 1; i*i <= n; ++i) {
    if (n % i) continue;
    res.push_back(i);
    if (n/i != i) res.push_back(n/i);
  }
  std::sort(res.begin(), res.end());
  return res;
}

template <typename InputIt>
auto compress(InputIt first, InputIt last) {
  using value_type = typename InputIt::value_type;
  std::map<value_type, size_t> res;
  while (first != last) res[*first++];
  size_t i = 0;
  for (auto& p: res) p.second = i++;
  return res;
}

template <typename Tp>
Tp gcd(Tp a, Tp b, Tp& x, Tp& y) {
  x = Tp(0);
  y = Tp(1);
  for (Tp u = y, v = x; a;) {
    Tp q = b/a;
    std::swap(x -= q*u, u);
    std::swap(y -= q*v, v);
    std::swap(b -= q*a, a);
  }
  return b;
}

template <typename Tp>
Tp modinv(Tp a, Tp mod) {
  Tp x, y;
  gcd(a, mod, x, y);
  x %= mod;
  if (x < 0) x += mod;
  return x;
}

template <typename Tp>
Tp modadd(Tp a, Tp b, Tp mod) {
  a += b % mod;
  if (a < 0) a += mod;
  if (a >= mod) a -= mod;
  return a;
}

template <typename Tp>
Tp modadd(std::initializer_list<Tp> const& adds, Tp mod) {
  Tp res = 0;
  for (auto const& add: adds) {
    res += add % mod;
    if (res < 0) res += mod;
    if (res >= mod) res -= mod;
  }
  return res;
}

template <typename Tp>
Tp modsub(Tp a, Tp b, Tp mod) {
  a -= b % mod;
  if (a < 0) a += mod;
  if (a >= mod) a -= mod;
  return a;
}

template <typename Tp>
Tp modmul(std::initializer_list<Tp> const& muls, Tp mod) {
  Tp res = 1;
  for (auto const& mul: muls) (res *= mul) %= mod;
  return res;
}

template <typename Tp>
Tp modpow(Tp base, intmax_t iexp, Tp mod) {
  Tp res = 1;
  for (Tp dbl = base; iexp; iexp >>= 1) {
    if (iexp & 1) res = res * dbl % mod;
    dbl = dbl * dbl % mod;
  }
  return res;
}

constexpr intmax_t  operator ""_jd(unsigned long long n) { return n; }
constexpr uintmax_t operator ""_ju(unsigned long long n) { return n; }
constexpr size_t    operator ""_zu(unsigned long long n) { return n; }
// constexpr ptrdiff_t operator ""_td(unsigned long long n) { return n; }

constexpr intmax_t mod = 1e9+7;

int main() {
  intmax_t n, k;
  scanf("%jd %jd", &n, &k);

  std::vector<intmax_t> ds = divisor(n);
  std::map<intmax_t, size_t> map = compress(ds.begin(), ds.end());
  std::vector<size_t> dp(map.size());
  intmax_t inv2 = modpow(2_jd, mod-2, mod);
  for (auto d: ds) {
    intmax_t cur = modpow(k, (d+1)/2, mod);
    for (auto d0: ds) {
      if (d == d0) break;
      if (d % d0) continue;
      cur = (cur + mod - dp[map.at(d0)]) % mod;
    }
    dp[map.at(d)] = cur;
  }

  intmax_t res = 0;
  for (auto d: ds) {
    intmax_t cur = dp[map.at(d)];
    (cur *= d) %= mod;
    if (d % 2 == 0) (cur *= inv2) %= mod;
    (res += cur) %= mod;
  }
  printf("%jd\n", res);
}


Measured memory_bytes: 384
#include<stdio.h>

int n,i,x,d[9];

int main(){
	scanf("%d",&n);
	while(n!=0){
		for(i=0;i<7;i++)d[i]=0;
		while(n--){
			scanf("%d",&x);
			if(x<10)d[0]++;
			else if(x<20)d[1]++;
			else if(x<30)d[2]++;
			else if(x<40)d[3]++;
			else if(x<50)d[4]++;
			else if(x<60)d[5]++;
			else d[6]++;
		}
		for(i=0;i<7;i++)printf("%d\n",d[i]);
		scanf("%d",&n);
	}
	
	return 0;
}

Measured memory_bytes: 404
/*    
                                                                             
	1. Practice makes a man perfect.
	2. Let go of the past.
	3. Without pain, without sacrifice, we would have nothing.
	4. Great things never come from comfort zones.
	5. Turn your wounds into wisdom.
	6. No pain ... no palm, no throne, no glory,no cross, no crown.
	7. You never know how strong you are until being strong is your only choice.
	8. Smooth seas do not make skillful sailors.
	9. I am not what happened to me, I am what I choose to become.
	10. No matter how fail life pushes you down, No matter how much you hurt,You can always bounce back.
		
		
	--> This lines keep me motivated.		

	Author:- Gaurang_Kothiya
	
*/
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>  
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
#include <bitset>
#include <cstdint>
#include <initializer_list>
 
using namespace std;
using namespace __gnu_pbds;  

#define data_set(type) tree<type,null_type,less<type>,rb_tree_tag,tree_order_statistics_node_update>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long int
#define ld long double
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fe(x,v)   for(auto &x :v)
#define nf(i,x,n) for(int i=n;i>=x;i--)
#define all(a)   a.begin(),a.end()
#define rall(a)  a.rbegin(),a.rend()
#define ook(num) order_of_key(num)
#define fbo(num) find_by_order(num)
#define gcd(a,b) __gcd(a,b)
#define bits(n) __builtin_popcountll(n)
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define RE rend()
#define RB rbegin()
#define B begin()
#define E end()
#define acc(v, x) accumulate(all(v), x)
#define p(a,b) pair<a,b>
#define F first
#define S second
#define sz size()
#define v(x) vector<x>
#define m(a,b) map<a,b>
#define u_m(a,b) unordered_map<a,b>
#define mm(a,b) multimap<a,b>
#define s(a) set<a>
#define us(a) unordered_set<a>
#define ms(a) multiset<a>
#define maxy __LONG_LONG_MAX__
#define miny INT_MIN
#define PI 3.14159265358979323846

const int inf= 1e9 +1;
const int inf64= 1e18 -1;
const int MOD= 1e9 +7;


 
void Solve()
{	
	int a[]={8,7,6,5,4,3,2,1};
	int n;
	cin>>n;
	n -=400;
	cout<<a[n/200];
}
 
signed main() 
{
	speed		

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int q=1;
	//cin>>q;
	
	while(q--)
	Solve();
		
	return 0;
} 

Measured memory_bytes: 3620
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever while (true)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
using namespace std;
// clang-format on

main {
  int a, b, c;
  cin >> a >> b >> c;
  cout << (a < b && b < c ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3096
import sys
input = sys.stdin.readline

# C - Many Requirements
import copy

n, m, q = map(int, input().split())
seq_arr = []

for i in range(1, m + 1):
	seq_arr.append([i])

for i in range(n):
	tmp_arr = []
	
	for s in seq_arr:
		for j in range(s[-1], m + 1):
			tmp_arr.append(s + [j])

	seq_arr = copy.deepcopy(tmp_arr)

queries = []

for i in range(q):
	a, b, c, d = map(int, input().split())
	queries.append([a-1, b-1, c, d])

ans = 0

for seq in seq_arr:
	sum = 0
	
	for query in queries:
		a, b, c, d = query
		
		if seq[b] - seq[a] == c:
			sum += d
			
	ans = max(ans, sum)

print(ans)

Measured memory_bytes: 216936
#include<iostream>
#include<cstring>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#define pb push_back
#define ll long long
#define ff first
#define ss second
using namespace std;

int n,m;
vector<int> v[100001];
vector<int> sink;
vector<int> src[100001];
int dp[100001];

int fun(int i){
    for(int j=0;j<sink.size();j++){
        if(i==sink[j]){
            return 0;
        }
    }
    if(dp[i]!=-1){
        return dp[i];
    }
    dp[i]=0;
    for(int j=0;j<v[i].size();j++){
         dp[i] = max(dp[i],fun(v[i][j])+1);
     }
     return dp[i];
}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>m;
    int x,y;
    for(int i=0;i<m;i++){
        cin>>x>>y;
        v[x].pb(y);
        src[y].pb(x);
    }
    for(int i=1;i<=n;i++){
        if(v[i].size()==0 && src[i].size()!=0){
            sink.pb(i);
        }
    }
    memset(dp,-1,sizeof(dp));
    int ans = 0;
    for(int i=1;i<=n;i++){
        if(src[i].size()==0 && v[i].size()!=0){
            ans = max(ans,fun(i));
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 16256
fn main() {
  let mut s = String::new();
  std::io::stdin().read_line(&mut s).unwrap();
  let N: i32 = s.trim().parse().unwrap();
  let mut ls: Vec<(i32, String, usize)> = vec![];
  for i in 0..N {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let s: String = iter.next().unwrap().chars().collect();
    let p: usize = iter.next().unwrap().parse().unwrap();
    ls.push((i+1, s, p));
  }
  ls.sort_by(|a,b| b.2.cmp(&a.2));
  ls.sort_by(|a,b| a.1.cmp(&b.1));
  for (i,_,_) in ls {
    println!("{}", i);
  }
}

Measured memory_bytes: 2116
#include<stdio.h>
int selectionSort(int* ,int);
int main(){
  int i,sw,A[100],N;
  scanf("%d",&N);
  for(i=0;i<N;i++)
    scanf("%d",&A[i]);
  sw=selectionSort(A,N);
  for(i=0;i<N;i++){
    if(i>0)printf(" ");
  printf("%d",A[i]);
  }
  printf("\n%d\n",sw);
  return 0;
}
int selectionSort(int A[],int N){
  int j,i,minj;
  int sw=0,swap;
  for(i=0;i<=N-1;i++){
    minj=i;
    for(j=i;j<=N-1;j++){
      if(A[j]<A[minj])
      minj=j;
    }
    if(i!=minj){
      swap=A[i];
      A[i]=A[minj];
      A[minj]=swap;
      sw++;
    }
  }
  return sw;
}

Measured memory_bytes: 604
import sys
input = sys.stdin.readline


def read():
    N, A, B = map(int, input().strip().split())
    S = input().strip()
    return N, A, B, S

def solve(N, A, B, S):
    na = 0
    nb = 0
    for s in S:
        if s == 'a' and na + nb < A + B:
            na += 1
            print('Yes')
        elif s == 'b' and na + nb < A + B and nb < B:
            nb += 1
            print('Yes')
        else:
            print('No')

if __name__ == '__main__':
    inputs = read()
    solve(*inputs)


Measured memory_bytes: 4016
#include<bits/stdc++.h>
using namespace std;
int main(){
	int m,d;cin>>m>>d;
  	int ans=0;
  	for(int i=1;i<=m;i++){
    	for(int j=1;j<=d;j++){
        	if((((j/10)>=2)&&((j%10)>=2))&&(((j/10)*(j%10))==i)){ans++;}
        }
    }
  	cout<<ans;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
 
#define iter(i, n) for (int i = 1; i <= n; ++i)
#define forw(i, a, b) for (int i = a; i <= b; ++i)
#define NR 101000
 
const int mod = 1000000007;
 
int n, f[NR], sum[NR], L[NR], R[NR];
long long a[NR], dA, dB;
 
int main() {
	scanf("%d%lld%lld", &n, &dA, &dB);
	if (dA > dB) swap(dA, dB);
	iter(i, n) scanf("%lld", &a[i]);
 
	int p = 0;
	forw(i, 2, n) {
		if (i > 2 && a[i] - a[i - 2] < dA) {
			printf("0\n");
			return 0;
		}
 
		L[i] = (a[i] - a[i - 1] >= dA) ? L[i - 1] : i - 1;
		for (; a[i] - a[p + 1] >= dB; ++p);
		R[i] = p;
	}
 
	f[0] = sum[0] = 1;
	L[1] = R[1] = 0;
 
	iter(i, n) {
		if (L[i-1] <= R[i]) f[i] = (sum[R[i]] - (L[i - 1] > 0 ? sum[L[i - 1] - 1] : 0) + mod) % mod;
		sum[i] = (sum[i - 1] + f[i]) % mod;
//printf("%d %d %d\n", f[i], L[i - 1], R[i]);
	}
 
	printf("%d\n", (sum[n] - (L[n] > 0 ? sum[L[n] - 1] : 0) + mod) % mod);
	return 0;
}

Measured memory_bytes: 2560
package main

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

func main() {
	var N int
	fmt.Scan(&N)
	sc := bufio.NewScanner(os.Stdin)
	var s string
	if sc.Scan() {
		s = sc.Text()
	}
	slice := strings.Split(s, " ")
	var inputsArray []int
	for i := 0; i < N; i++ {
		bar, _ := strconv.Atoi(slice[i])
		inputsArray = append(inputsArray, bar)
	}
	result := 0
  breakflag := 0
	for {
		for _, s := range inputsArray {
          nino:=int(math.Pow(2, float64(result)))
          if s%nino != 0 {
            	breakflag = 1
				break
			}
		}
      if breakflag==1{
      break
      }
		result += 1
	}
  fmt.Println(result-1)

}


Measured memory_bytes: 640
from collections import deque

h,w = map(int,input().split())
cy,cx = map(int,input().split())
dy,dx = map(int,input().split())
s = [input() for j in range(h)]

chk = [[-1]*(w) for _ in range(h)]

seg = [[] for _ in range(h*w)]

div = 0

vx = [0,1,0,-1]
vy = [1,0,-1,0]

q = deque()
q.appendleft([cy-1,cx-1,0])
#seg[0].append([c[0],c[1],div])
while len(q) > 0:
    y,x,div = q.popleft()
    #print(y,x,div)
    if chk[y][x] != -1:
        continue
    chk[y][x] = div
    for i in range(4):
        y_n = y + vy[i]
        x_n = x + vx[i]
        if y_n >= 0 and y_n <= h-1 and x_n >= 0 and x_n <= w-1:
            if s[y_n][x_n] == '.':
                if chk[y_n][x_n] == -1:
                    q.appendleft([y_n,x_n,div])
                    
    for i in range(5):
        for j in range(5):
            y_n = y + (-2+i)
            x_n = x + (-2+j)
            
            if y_n >= 0 and y_n <= h-1 and x_n >= 0 and x_n <= w-1:
                if s[y_n][x_n] == '.':
                    if chk[y_n][x_n] == -1:
                        q.append([y_n,x_n,div+1])
                        
                        
print(chk[dy-1][dx-1])
#print(chk)
        



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

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

void solve(){
    string S; int K; cin >> S >> K;
    int N = S.size();
    for(int i = 0; i < N; ++i){
        if(S[i] == 'a') continue;
        int nokori = 26 - (S[i] - 'a');
        if(nokori <= K){
            S[i] = 'a';
            K -= nokori;
        }
    }
    S[N - 1] = S[N - 1] + (K % 26);
    cout << S << '\n';
}



int main() {
    #ifdef MYLOCAL
    const int CASES = 3;
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
    #else

    solve();

    #endif
    return 0;
}



Measured memory_bytes: 640
import sys

n, k = map(int, input().split())
a = [int(x) for x in input().split()]
mod = pow(10, 9)+7
zero = 0
plus = []
minus = []
for i in range(n):
  if a[i] == 0:
    zero += 1
  elif a[i] > 0:
    plus.append(a[i])
  else:
    minus.append(a[i])

P, M = len(plus), len(minus)
plus.sort(reverse=True)
minus.sort()
ans = 1
if n == k:
  for i in range(n):
    ans *= a[i]
    ans %= mod
elif P+M < k:
  ans = 0
elif P == 0:
  if zero and k%2:
    ans = 0
  else:
    if k%2:
      minus.reverse()
    for i in range(k):
      ans *= minus[i]
      ans %= mod
else:
  q = 0
  if k%2:
    ans *= plus[0]
    ans %= mod
    q = 1
  judge = []
  for i in range((len(plus)-q)//2):
    judge.append(plus[2*i+q]*plus[2*i+q+1])
  for i in range(len(minus)//2):
    judge.append(minus[2*i]*minus[2*i+1])
  judge.sort(reverse=True)
  for i in range(k//2):
    ans *= (judge[i]%mod)
    ans %= mod

print(ans)


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

using namespace std;
using Graph = vector<vector<int>> ;
Graph G;

void dfs(int v, vector<bool> &seen, int & res){
    bool end  = true; //すべての頂点を探索済か否かを表す
    for(int i = 0; i < seen.size(); i++){
        if(!seen[i] && i != v){ 
            end = false; //頂点 v 以外の頂点を一通り全て探索済みかどうか調べる. 探索していない点が存在すれば falseを返しておく
        }
    }
    if(end){
        res++; //すべての頂点を探索したことがわかったら答えをインクリメントした上でリターンする
        return;
    }

    seen[v] = true; //その頂点を訪問済みにする
    for(auto nv: G[v]){ //vの隣接する点を調べる
        if(seen[nv])continue; //vの隣接する点の中ですでに訪問済みの点の場合は調べない（重複防止）
        dfs(nv, seen, res); //vの隣接する点についてdfsを行って再帰的に調べる
    }

    seen[v] = false;
}

int main(void){
    int N, M;
    cin >> N >> M;
    G.assign(N, vector<int>()); // グラフ入力受取 (ここでは無向グラフを想定)
    for(int i = 0; i < M; i++){
        int a, b;
        cin >> a >> b;
        --a; //0-indexのためデクリメント
        --b; //0-indexのためデクリメント
        G[a].push_back(b); //隣接リストを作る
        G[b].push_back(a); //隣接リストを作る
    }
    vector<bool> seen(N, false); //seen: その頂点を検知済みかどうかを表す配列
    int number_of_Hamilton_path = 0;
    dfs(0, seen, number_of_Hamilton_path); //dfs(parent, 検知済み配列, pathの数)
    cout << number_of_Hamilton_path  << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#define int long long
#define mod 1000000007
using namespace std;
int n, a[234567], b[234567];
signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i]; b[i] = a[i];
	}
	sort(b, b + n);
	for (int i = 0; i < n; i++) {
		if (a[i] == b[n-1])cout << b[n-2] << endl;
		else cout << b[n-1] << endl;
	}
}

Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    //ios_base::sync_with_stdio(0);
    int a;
    while(cin>>a){
        for(int i=1; i<=9; i++){
            for(int j=1; j<=9; j++){
                if(i*j==a){
                    cout<<"Yes"<<endl;
                    return 0;
                }
            }
        }
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>

struct A{
  int id;
  int n;
  int c[101];
};

int main(){
  int n,i,j,a;
  scanf("%d",&n);
  struct A A[n];
  for(i=0;i<n;i++){
    for(j=1;j<=n;j++){
      A[i].c[j] =0;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&A[i].id,&A[i].n);
    if(A[i].n!=0){
      for(j=0;j<A[i].n;j++){
        scanf("%d",&a);
        A[i].c[a]=1;
      }
    }
  }

  for(i=0;i<n;i++){
    for(j=1;j<=n;j++){
      if(j!=n){
        if(A[i].c[j]>=1){
          printf("1 ");
        }
        else printf("0 ");
      }
    else{
      if(A[i].c[j]==1){
        printf("1\n");
      }
      else printf("0\n");
    }
  }
  }
  return 0;
}



Measured memory_bytes: 2112
N=int(input())
n_list=list(map(int,input().split(' ')))
M=int(input())
q = list(map(int,input().split(' ')))
ans = []
for i in range(2**N):
    str_bin = format(i,'0{}b'.format(N))
    tmp = 0
    for n,j in enumerate(str_bin):
        if j=='1':
           tmp += n_list[n]
    ans.append(tmp)
ans = set(ans)
for i in q:
    if i in ans:
        print('yes')
    else:
        print('no')


Measured memory_bytes: 43088
#define _GLIBCXX_DEBUG
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;

int P[10010];
void init(int n){
    for(int i=0;i<n;++i)P[i]=i;
}
int root(int a) {
    if(P[a]==a)return a;
    return (P[a]=root(P[a]));
}
bool is_same_set(int a,int b){
    return root(a) == root(b);//代表元を求める
}
void unite(int a,int b){
    P[root(a)]=root(b);
}//対set,グラフ？

double dot_product(xy_t a, xy_t b) { return (conj(a)*b).real(); }//内積
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }//外積
xy_t projection(xy_t p, xy_t b) { return b*dot_product(p,b)/norm(b); }//投影
//対図形

#define mod 1000000007
ll f[2001];
//int n,k とかしておく

ll pw(ll x, ll y){//euclidの互除法より
    ll a= 1;
    while(y){
        if(y&1){//奇数なら
            a = a*x%mod;
        }
        x = x*x%mod;
        y /= 2;
    }
    return a;
}

ll modinv(ll x){//逆元を求める
    return pw(x, mod - 2 );
}

ll comb(int n,int r){
    if(n<r){
        return 0;
    }
    return f[n] * modinv(f[r])%mod*modinv(f[n-r])%mod;
}//対combination

int main(){
    int r;
    cin >>r;
    cout<<3*r*r<<endl;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> x(N),y(N);
  for (int i=0; i<N; i++){
      cin >> x.at(i) >> y.at(i);
  }
  double s=0;
  for (int i=0; i<N; i++){
      for(int j=i+1; j<N; j++){
          s += pow(pow(x.at(i)-x.at(j),2)+pow(y.at(i)-y.at(j),2),0.5);
      }
  }
  cout << fixed << setprecision(10) << s*2/N;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
using namespace std;
int main(void){
    int n;
    cin >> n;
    int a[n];
    int sum = 0;
    for(int i = 0;i < n;i++){
        cin >> a[i];
        sum += a[i];
    }
    int ans = sum;
    for(int i = 0;i < n;i++){
        ans = min(ans,abs(sum - a[i] * 2));
        sum -= a[i] * 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
S = raw_input()
D = ["dream", "dreamer", "erase", "eraser"]

que = []
que.append(0)
while len(que) > 0:
    i = que.pop()
    if i == len(S):
        print "YES"
        exit()
    for d in D:
        ld = len(d)
        if S[i:i+ld] == d:
            que.append(i+ld)
print "NO"


Measured memory_bytes: 3076
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1000000000;

int main() {
    int x; cin >> x;
    if (x >= 30){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    
}

Measured memory_bytes: 3632
#include<cstdio>
#include<algorithm>
#include<cctype>
using namespace std;
#define G getchar()
int read()
{
	int x=0; char ch=G;
	for (;!isdigit(ch);ch=G);
	for (;isdigit(ch);ch=G) x=(x<<3)+(x<<1)+(ch^48);
	return x;
}
#undef G

int n,m;
char s[110][110];
int dp[110][110];
int main()
{
	n=read(),m=read();
	for(int i=1;i<=n;i++) scanf("%s",s[i]+1);
	for(int i=1;i<=n;i++)
		for (int j=1;j<=m;j++)
			dp[i][j]=1e9;
	dp[1][1]=(s[1][1]=='#');
	for(int i=1;i<=n;i++){
		for (int j=1;j<=m;j++){
			if (i+1<=n) dp[i+1][j]=min(dp[i+1][j],dp[i][j]+(s[i][j]=='.'&&s[i+1][j]=='#'));
			if (j+1<=m) dp[i][j+1]=min(dp[i][j+1],dp[i][j]+(s[i][j]=='.'&&s[i][j+1]=='#'));
		}
	}
	printf("%d\n",dp[n][m]);
	return 0;
}

Measured memory_bytes: 256
local mod=1000000007

local function bmul(x,y)
    return (x*y)%mod
end

local function badd(x,y)
    return (x+y)%mod
end

local function bsub(x,y)
  return x<y and x-y+mod or x-y
end

local function bmod(x)
    x=tostring(x)
    local ten=10
    local cry=1
    local xod=0
    for i=#x,1,-1 do
        local xub=tonumber(x:sub(i,i))
        xod=(xod+xub*cry)%mod
        cry=(cry*ten)%mod
    end
    return xod
end

local function bpow(x,y)
    x=bmod(x)
    y=bmod(y)
    local xpy=1
    while 0<y do
        if y%2==1 then
            xpy=bmul(xpy,x)
            y=y-1
        end
        x=bmul(x,x)
        y=y//2
    end
    return xpy
end

local function comb(x,y)
    local xyi=1
    local yii=1
    for i=1,y do
        xyi=bmul(xyi,x+1-i)
        yii=bmul(yii,i)
    end
    return bmul(xyi,bpow(yii,mod-2))
end

local n,a,b=io.read("n","n","n")
local total=bpow(2,n)-1
local comba=comb(n,a)
local combb=comb(n,b)
print(bsub(total,badd(comba,combb)))

Measured memory_bytes: 2800
//Credits to http://tokoharuland.hateblo.jp/entry/2018/04/01/155743
//Good explanation at http://koba-e964.hatenablog.com/entry/2019/01/14/200541
//Try to use google translate (in case you don't understand japanese)
#include <bits/stdc++.h>
#define FI first
#define SE second
#define PB push_back
#define endl '\n'
using namespace std;

typedef long long LL;

const int N = 5e5;
const LL INF = 1e18;
LL arr[N + 5];
vector<pair<int,LL> > vec[N + 5];
vector<pair<LL, pair<int,int> > > edges;

int par[N + 5];
int col[N + 5];
LL dist[N + 5];

int find(int x) {
	if(x == par[x]) return x;
	return par[x] = find(par[x]);
}

LL voronoiGraphMST(int n) {
	for(int i = 1;i <= 2 * n;i++) par[i] = i, col[i] = -1;
	priority_queue<pair<LL, pair<int,int> > > pq; //cost, idx, color
	for(int i = 1;i <= n;i++) pq.push({0, {i, i}});
	while(!pq.empty()) {
		LL cost = -pq.top().FI;
		int idx = pq.top().SE.FI;
		int color = pq.top().SE.SE;
		pq.pop();
		if(col[idx] == -1) { //If this vertex hasn't been visited
			dist[idx] = cost; 
			col[idx] = color; //mark this vertex with current color
			for(int i = 0;i < vec[idx].size();i++) {
				int nx = vec[idx][i].FI;
				LL ncost = vec[idx][i].SE;
				pq.push({-cost - ncost, {nx, color}});
			}
		} else {
			if(color != col[idx]) { 
				//if the color is different, then it must be intersection ofboth vertices
				edges.PB({cost + dist[idx],{col[idx], color}}); //potential edges
			}
		}
	}
	//Do the usual MST
	LL res = 0;
	sort(edges.begin(), edges.end());
	for(int i = 0;i < edges.size();i++) {
		LL ct = edges[i].FI;
		int u = edges[i].SE.FI;
		int v = edges[i].SE.SE;
		if(find(u) != find(v)) {
			res += ct;
			par[find(u)] = find(v);
		}
	}
	return res;
}

void solve() {
	int n;
	cin>>n;
	for(int i = 1;i <= n;i++) {
		cin>>arr[i];
		vec[i].PB({i + n, arr[i]});
		vec[i + n].PB({i, arr[i]});
	}
	for(int i = 1;i < n;i++) {
		int u,v,w;
		cin>>u>>v>>w;
		vec[u + n].PB({v + n, w});
		vec[v + n].PB({u + n, w});
	}
	cout<<voronoiGraphMST(n)<<endl;
}

int main(){
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	solve();
	return 0;
}




Measured memory_bytes: 77540
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main(){
  long double n,k;
  cin >> n >> k;
  int p,i;
  long double x=0;
  for(i=1;i<=n;i++){
    p=0;
    while(1){
      if(i*pow(2,p)<k) p++;
      else break;
    }
    x += 1/n*pow(0.5,p);
  }
  cout << fixed << setprecision(15) << x << "\n";
  return 0;
}

Measured memory_bytes: 4200
//*******Abhijit Burman***********//
//Jalpaiguri Government Engineering College//

// Taken From Striver_79
// Never open a ranklist untill and unless you are done with solving problems, wastes 3/4 minuts 
// Donot treat CP as a placement thing, love it and enjoy it, you will succeed for sure. 


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define ff first
#define ss second
#define mk make_pair
#define MAXX (1000000000000000000+7)
#define mod 1000000007
#define endl "\n"
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
void input(ll a[], ll sz) {for(ll i=0;i<sz;i++) cin >> a[i];}
void print(ll a[], ll sz) {for(ll i=0;i<sz;i++) {if (i == sz - 1) cout << a[i] << "\n"; else cout << a[i] << " ";}}
ll dx1[] = {1, 1, 0, -1, -1, -1, 0, 1};
ll dy1[] = {0, 1, 1, 1, 0, -1, -1, -1};

ll dx2[] = {1, 0, -1, 0};
ll dy2[] = {0, 1, 0, -1};

ll mul(ll a, ll b, ll p = mod) {return ((a % p) * (b % p)) % p;}
ll add(ll a, ll b, ll p = mod) {return (a % p + b % p) % p;}
ll power(ll x,ll y,ll p = mod) 
{ 
    ll res = 1;
    x = x % p;
    while (y > 0) 
    {
        if (y & 1) 
            res = (res*x) % p;
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
} 
ll modInverse(ll n, ll p = mod)
{
    return power(n, p - 2, p);
}
ll ncrMod(ll n, ll r, ll p = mod)
{
    if (r == 0)
        return 1;
    ll fac[n + 1];
    fac[0] = 1;
    for (ll i = 1 ; i <= n; i++)
        fac[i] = fac[i - 1] * i % p;
    return (fac[n] * modInverse(fac[r], p) % p *
            modInverse(fac[n - r], p) % p) % p;
}
// a+b=xor(a,b)+2*(a&b)//

bool isPrime(ll n){
    for(int i=2;i*i<=n;i++){
        if(n%i==0){
            return false;
        }
    }
    return true;
}


void solve()
{
    ll n;
    cin>>n;
    ll a[n];
    input(a,n);
    
    ll res=0;
    
    ll pre[n];
    pre[0]=a[0];
    for(int i=1;i<n;i++){
        pre[i]=pre[i-1]+a[i];
    }
    ll temp;
    for(int i=n-2;i>=0;i--){
        temp = mul(pre[i],a[i+1]);
        res = add(res,temp);
    }
    
    cout<<res<<endl;
}


int main()
{
	fio;
// 	#ifndef ONLINE_JUDGE
//     // for getting input from input.txt
//     freopen("input.txt", "r", stdin);
//     // for writing output to output.txt
//     freopen("output.txt", "w", stdout);
// 	#endif
 

	ll t=1;
// 	cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

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

int main() {
  int W, H, x, y, r;
  cin >> W >> H >> x >> y >> r;
  
  if (0 <= x && x <= W && 0 <= y && y <= H) {
    if(x-r >= 0 && x+r <= W && y-r >= 0 && y+r <= H)
      cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  else cout << "No" << endl;
  
  return 0;
}


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

int main()
{
        int n, x, count=0;

        while(cin>>n>>x){
                if(n==0 && x==0){break;}
                count = 0;
                for(int i=1; i<=n; i++){
                        for(int j=i+1; j<=n; j++){
                                for(int k=j+1; k<=n; k++){
                                        if(i+j+k==x){count++;}
                                }
                        }
                }
                cout << count << endl;
        }
         
        return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
/* ------------------------------------------------ */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcm(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcm(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcm(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ------------------------------------------------ */

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int k;
    cin >> k;
    k--;
    rep(i, n) {
        if(s[i] != s[k]) s[i] ='*';
    }
    cout << s << endl;

}

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

#define MAX 10	// ªºÌ

int main()
{
	int x, y, d;
	int oblong = 0, rhombi = 0;

	while (scanf("%d,%d,%d", &x, &y, &d) != EOF) {
		if (x*x + y*y == d*d) oblong++;
		if (x == y) rhombi++;
	}
	cout<<oblong<<endl;
	cout<<rhombi<<endl;

	return 0;
}

Measured memory_bytes: 0
N,C=map(int,input().split())
li=[list(map(int,input().split())) for i in range(N)]

cumR=[0]*(N+1)
cummaxR=[0]*(N+1)
for i in range(N):
    cumR[i+1]=cumR[i]+li[i][1]-li[i][0]
    cummaxR[i+1]=cummaxR[i]+li[i][1]-li[i][0]*2
    if i>0:
        cumR[i+1]+=li[i-1][0]
        cummaxR[i+1]+=li[i-1][0]*2
for i in range(1,N):
    cummaxR[i]=max(cummaxR[i],cummaxR[i-1])
cumL=[0]*(N+1)
cummaxL=[0]*(N+1)
for i in reversed(range(N)):
    cumL[i]=cumL[i+1]+li[i][1]-(C-li[i][0])
    cummaxL[i]=cummaxL[i+1]+li[i][1]-(C-li[i][0])*2
    if i<N-1:
        cumL[i]+=(C-li[i+1][0])
        cummaxL[i]+=(C-li[i+1][0])*2
for i in reversed(range(N)):
    cummaxL[i]=max(cummaxL[i],cummaxL[i+1])
ans=0
for i in range(N):
    ans=max(ans,cumR[i+1]+cummaxL[i+1])
    ans=max(ans,cumL[i]+cummaxR[i])
print(ans)

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

int main() {
	int n,x,a;
	int mn=0,cnt=0;
	cin >> n >> x;
	for(int i=1;i<=n;i++) {
		cin >> a;
		mn+=a;
		if(mn<=x) cnt++;
		}
		cout << cnt+1;
	return 0;
}

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

# 1-0-1-0-1の形式で集計する
count=0
now=1
num_list=[]
for c_i in s:
    if c_i == now:
        count+=1
    else:
        num_list.append(count)
        count=1
        now=1-now
num_list.append(count)

# 最後が0のグループだと都合が悪い
if len(num_list)%2==0:
    num_list.append(0)

# 累積和を使って部分列の合計の最大値を求める
max_len=0
now_sum=0
left=0
right=0

for i in range(0,len(num_list),2):
    nextleft=i
    nextright=min(len(num_list),i+2*k+1)

    while left<nextleft:
        now_sum-=num_list[left]
        left+=1
    while right<nextright:
        now_sum+=num_list[right]
        right+=1
    max_len=max(max_len,now_sum)
    
print(max_len)

Measured memory_bytes: 4776
#include<iostream>

using namespace std;

int main(void) {
	int n;
	int m = 0;
	cin >> n;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int tmp;
		cin >> tmp;
		if (tmp >= m) {
			ans++;
			m = tmp;
		}
	}
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 256
def calc():
    N,Ma,Mb = map(int, input().split())
    arr=[list(map(int,input().split())) for _ in range(N)]
    dp=[[[5000]*401 for _ in range(401)] for _ in range(41)]
    dp[0][0][0] = 0
    for i in range(N):
        a,b,c=arr[i]
        for j in range(10*N+1):
            for k in range(10*N+1):
                if dp[i][j][k] == 5000:
                    continue
                dp[i+1][j][k]=min(dp[i+1][j][k],dp[i][j][k])
                dp[i+1][j+a][k+b]=min(dp[i+1][j+a][k+b],dp[i][j][k]+c)

    ans=5000
    for i in range(1,401):
            if i*Ma>400 or i*Mb>400:
                break
            ans = min(ans, dp[N][i*Ma][i*Mb])
    if ans == 5000:
        print(-1)
    else:
        print(ans)

calc()

Measured memory_bytes: 59504
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = Integer.parseInt(scan.next());
        }
        scan.close();

        int all = a[0];
        for (int i = 1; i < n; i++) {
            all ^= a[i];
        }

        for (int i = 0; i < n; i++) {
            System.out.print((all ^ a[i]) + " ");
        }
        System.out.println("");
    }

}


Measured memory_bytes: 61436
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define SZ 666666
int n; ll s[SZ];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
		scanf("%lld",s+i),s[i]+=s[i-1];
	map<ll,ll> m;
	for(int i=0;i<=n;++i) ++m[s[i]];
	ll ans=0;
	for(auto t:m)
		ans+=t.se*(t.se-1)/2;
	cout<<ans<<"\n";
}


Measured memory_bytes: 14336
def cnt(n,d)
  n-n/d
end
A,B,C,D=gets.split.map &:to_i
c=cnt(B,C)-cnt(A-1,C)
d=cnt(B,D)-cnt(A-1,D)
cd=cnt(B,C.lcm(D))-cnt(A-1,C.lcm(D))
p c+d-cd

Measured memory_bytes: 1788
def divisor(n):
    divisors=[]
    for i in range(1,int(n**0.5+1)):
        if n%i==0:
            divisors.append(i)
            if i!=n//i:
                divisors.append(n//i)
    divisors.sort()
    return divisors
n=int(input())
ans=0
for i in range(2,n+1):
    num=divisor(i)
    if i%2==1 and len(num)==8:
        ans+=1
print(ans)


Measured memory_bytes: 38512
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
#define lc (rt << 1)
#define rc (rt << 1) | 1
using namespace std;
typedef long long LL;
const int N = 5005;

template <typename T> inline void read(T &AKNOI) {
	T x = 0, flag = 1;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-') flag = -1;
		ch = getchar();
	}
	while (isdigit(ch)) {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	AKNOI = flag * x;
}

int n, A, B, p[N];
LL mn[N << 2], tag[N << 2];

inline void pushup(int rt) {
    mn[rt] = min(mn[lc], mn[rc]);
}

inline void puttag(int rt, LL tg) {
    mn[rt] += tg;
    tag[rt] += tg;
}

inline void pushdown(int rt) {
    if (tag[rt]) {
        puttag(lc, tag[rt]);
        puttag(rc, tag[rt]);
        tag[rt] = 0;
    }
}

void SetVal(int rt, int b, int e, int p, LL val) {
    if (b == e) {
        mn[rt] = val;
        return;
    }
    int mid = (b + e) >> 1;
    pushdown(rt);
    if (p <= mid) SetVal(lc, b, mid, p, val);
    else SetVal(rc, mid + 1, e, p, val);
    pushup(rt);
}

void Update(int rt, int b, int e, int l, int r, LL val) {
    if (l <= b && e <= r) {
        puttag(rt, val);
        return;
    }
    int mid = (b + e) >> 1;
    pushdown(rt);
    if (l <= mid) Update(lc, b, mid, l, r, val);
    if (r > mid) Update(rc, mid + 1, e, l, r, val);
    pushup(rt);
}

LL Query(int rt, int b, int e, int l, int r) {
    if (l <= b && e <= r) return mn[rt];
    int mid = (b + e) >> 1;
    pushdown(rt);
    if (r <= mid) return Query(lc, b, mid, l, r);
    if (l > mid) return Query(rc, mid + 1, e, l, r);
    return min(Query(lc, b, mid, l, r), Query(rc, mid + 1, e, l, r));
}

void solve() {
    read(n); read(A); read(B);
	for (int i = 1; i <= n; ++i) {
        read(p[i]);
	}
    mset(mn, 0x3f);
    SetVal(1, 0, n, 0, 0);
	for (int i = 1; i <= n; ++i) {
	    LL tmp = Query(1, 0, n, 0, p[i] - 1);
	    SetVal(1, 0, n, p[i], tmp);
        Update(1, 0, n, 0, p[i] - 1, A);
        if (p[i] <n) Update(1, 0, n, p[i] + 1, n, B);
	}
	printf("%lld\n", mn[1]);
}

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



Measured memory_bytes: 512
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;
#define int ll

void YES(bool ok){
    cout << (ok ? "Yes" : "No") << endl;
}
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    bool ok = false;
    for(int i = 0; i * 4 <= n; i++){
        if((n - i*4) % 7 == 0)ok = true;
    }

    YES(ok);
}

Measured memory_bytes: 256