akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T iabs(const T& x) { return max(x, -x); }
// #define abs gabs

int h, w, n;
int main() {
    cin >> h >> w >> n;
    cout << min((n + h - 1) / h, (n + w - 1) / w) << endl;
    return 0;
}

Measured memory_bytes: 888
//-------All power is within you,you can do Anything and Everything.---------//
 
    #include <bits/stdc++.h>
    using namespace std;
  
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ M $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
 
    #define pb push_back
    #define MP make_pair
    #define F first
    #define S second
    #define int long long
    #define fo(i,a,b) for(int i=a;i<b;i++)
    #define rfo(i,b,a) for(int i=b;i>=a;i--)
    #define deb(x) cout<<#x<<" "<<x<<endl;
    #define mem( a, val ) memset(a, val, sizeof( a ) )
    #define deci( x ) cout<<fixed<<setprecision( x );
    #define bitcount( x ) __builtin_popcountll( x )
 
    
    typedef vector<int> vi;
    typedef pair<int,int> pi; 
    
    const int MOD =  1000000007 ;
    const int MAX = 2e6 + 7;
    const int dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
    const int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
 
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ V $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//  
    
    int i,j,k,t,n,q,l,r,mid;
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ F $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
    
    
    int dis[MAX],vis[MAX];
    vector<int> adj[MAX];
    int in_deg[MAX];
    int x,y,maxi,b,m;
    
    void dfs(int a)
    {
        vis[a]=1;
        fo( i,0,adj[a].size())
        {
            b=adj[a][i];
            dis[b]=max(dis[b],dis[a]+1);
            in_deg[b]--;
            if(in_deg[b]==0)
            {
                // deb(b)
                dfs(b);
            }
            // dfs(b);
        }
    }
 
    void solve()
    {
        cin>>n>>m;
        fo(i,0,m)
        {
            cin>>x>>y;
            adj[x].push_back(y);
            in_deg[y]++;
        }
        
        fo(i,1,n+1)
        if(vis[i]==0 && in_deg[i]==0)
        dfs(i);
        
        maxi=0;
        fo(i,0,n+1)
        maxi=max(dis[i],maxi);
        cout<<maxi<<endl;
        
    	
    }
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
//                          GAME STARTS FROM HERE                            //
 
    int32_t main() 
      {
      	
      	// int start,stop=clock();
        // cout<<"time:"<<(stop-start)/double(CLOCKS_PER_SEC)*1000<<endl;
      	ios_base::sync_with_stdio(0);
      	cin.tie(NULL);
      	
      	// cin>>t;while(t--)
      	solve();
      	
    	return 0;
      }

Measured memory_bytes: 60032
#include<iostream>
#include<string>
#include<cstdio>
#include<map>
using namespace std;
typedef long long ll;
const ll p=10000000000000061;
struct Node{
	int cnt[26];
};
map<ll,Node> mp;
int n;
ll ans;
int cnt[26];
string s[200005];
int main(){
	ios::sync_with_stdio(false);
	ll hsh;
	int i,j,k;
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>s[i];
		hsh=0;
		for(j=(int)s[i].length()-1;j;j--)
			hsh=(hsh*27+s[i][j]-'a'+1)%p;
		mp[hsh].cnt[s[i][0]-'a']++;
	}
	for(i=1;i<=n;i++){
		hsh=0;
		for(j=0;j<26;j++)
			cnt[j]=0;
		for(j=(int)s[i].length()-1;j>=0;j--)
			cnt[s[i][j]-'a']++;
		for(j=(int)s[i].length();j;j--){
			if(j!=(int)s[i].length()){
				hsh=(hsh*27+s[i][j]-'a'+1)%p;
				cnt[s[i][j]-'a']--;
			}
			for(k=0;k<26;k++)
				if(cnt[k])
					ans+=mp[hsh].cnt[k];
		}
		ans--;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 166592
#include "bits/stdc++.h"

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

using LL = long long int;
using LD = long double;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
LL gcd(LL x, LL y) { return y ? gcd(y, x % y) : x; }

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

	vvi m(14, vi(14));

	char ch;
	int x, y, s;
	while (cin >> x >> ch >> y >> ch >> s){
		y += 2;
		x += 2;

		m[y][x]++;
		m[y + 1][x]++;
		m[y - 1][x]++;
		m[y][x + 1]++;
		m[y][x - 1]++;

		if (s == 1) {
			continue;
		}

		m[y + 1][x + 1]++;
		m[y + 1][x - 1]++;
		m[y - 1][x + 1]++;
		m[y - 1][x - 1]++;

		if (s == 2) {
			continue;
		}

		m[y + 2][x]++;
		m[y - 2][x]++;
		m[y][x + 2]++;
		m[y][x - 2]++;
	}

	int noInkGrid = 0;
	int maxInc = 0;
	for (int i = 2; i < 12; i++) {
		for (int j = 2; j < 12; j++) {
			if (m[i][j] == 0) {
				noInkGrid++;
			}
			maxInc = max(maxInc, m[i][j]);
		}
	}

	cout << noInkGrid << endl;
	cout << maxInc << endl;
	return 0;
}

Measured memory_bytes: 3108
#include <iostream>

using namespace std;

int main() {
    long n, d, result=0;
    cin >> n >> d;

    for (int i = 0; i < n; i++) {
        long x, y;
        cin >> x >> y;
        if (x * x + y * y <= d*d) {
            result++;
        }
    }

    cout << result << endl;
}

Measured memory_bytes: 3620
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]
for i in range(N):
	a.append(a[i] + A[i])
for i in range(M):
	b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
	if a[i] > K:
		break
	while b[j] > K - a[i]:
		j -= 1
	ans = max(ans, i + j)
print(ans)

Measured memory_bytes: 47620
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int smallest_cost(const std::vector<long long>& dp, const std::vector<int>& cost, int k, int i) {
    long long smallest = 1e10;
    for (int j = 1; j < k+1; ++j) {
        if (i-j < 1) continue;
        long long c = dp[i-j] + abs(cost[i] - cost[i-j]);
        if (c < smallest) smallest = c;
    }
    return smallest;
}

int main(int argc, char** argv) {
    int n, k;
    cin >> n >> k;

    std::vector<int> vec(n + 1);
    vec[0] = 0;
    for (int i = 1; i < n+1; ++i) {
        cin >> vec[i];
    }
    std::vector<long long> dp(n + 1);
    dp[0] = 0;
    dp[1] = 0;
    for (int i = 2; i < n+1; ++i) {
        dp[i] = smallest_cost(dp, vec, k, i);
    }
    cout << dp[n] << endl;

    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll MOD = 1000000007;
const long long INF = 1LL << 60;

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

int main()
{   
    int n;string s;
    cin >> n >> s;
    int dp[51]={0};
    for(int i=0;i+2<s.size();i++){
        string sub = s.substr(i,3);
        if(sub == "ABC")dp[i+1]=dp[i]+1;
        else dp[i+1]=dp[i];
    }
    cout << dp[s.size()-2] << endl;
}
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  string s,t,u;
  int a,b;
  cin >> s >> t >> a >> b >> u;
  if(s==u) cout << a-1 << " " << b << endl;
  else cout << a << " " << b-1 << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

S = readline().rstrip()
K = int(read())

def solve_small(S,K):
    T = S * K
    prev = 0
    cnt = 0
    for x in T:
        if x != prev:
            prev = x
            continue
        else:
            prev = 0
            cnt += 1
    return cnt

A = [solve_small(S,k) for k in [0,1,2,3,4,5]]

if K <= 5:
    answer = A[K]
else:
    if K&1:
        d = A[5] - A[3]
        answer = A[5] + (K-5)//2 * d
    else:
        d = A[4] - A[2]
        answer = A[4] + (K-4)//2 * d

print(answer)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

const int N = 222;
int dist[11][11], a[N][N];
int n, m;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    rep(i, 1, 10) {
        rep(j, 1, 10) {
            cin >> dist[i][j];
        }
    }
    rep(k, 1, 10) {
        rep(i, 1, 10) {
            rep(j, 1, 10) {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
    int ans = 0;
    rep(i, 1, n) {
        rep(j, 1, m) {
            cin >> a[i][j];
            if(a[i][j] >= 0) {
                ans += dist[a[i][j] + 1][2];
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define sz(arr) (int)(arr).size()
#define rng(arr) arr.begin(), arr.end()
#define show(x) cout << #x << " = " << x << endl;
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;
typedef long long int ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

#define Cins(T, n, xs) \
  vector<T> xs(n);     \
  for (int i = 0; i < n; ++i) cin >> xs[i]

void Main();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(15);
  Main();
  return 0;
}

void Main() {
  using pii = pair<int, int>;
  Cin(int, n, m);
  vector<pii> v(n);
  rep(i, n) cin >> v[i].first >> v[i].second;

  sort(rng(v));

  ll ans = 0;
  int cnt = 0;
  rep(i, n) {
    if (cnt == m) break;
    while (v[i].second > 0) {
      if (cnt == m) break;
      ans += v[i].first;
      v[i].second--;
      cnt++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define INF 0x3f3f3f3f
using namespace std;
const int Maxn=(1<<20);
int n,m,root,deg[Maxn],par[Maxn];
vector<int> adj[Maxn],radj[Maxn];
void read()
{
	cin>>n>>m;
	for (int i=0;i<n-1+m;i++)
	{
		int u,v;
		cin>>u>>v;
		adj[u].pb(v);
		deg[v]++;
		radj[v].pb(u);
	}
}
bool vis[Maxn];
void dfs(int u,int pr)
{
	vis[u]=true;
	par[u]=pr;
	for (int v: adj[u]) deg[v]--;
	for (int v: adj[u]) if (!vis[v] && deg[v]==0) dfs(v,u);
}
void solve()
{
	for (int i=1;i<=n;i++) if (!deg[i]) root=i;
	dfs(root,0);
	for (int i=1;i<=n;i++) cout<<par[i]<<endl;
}
int main()
{
	read();
	solve();
	return 0;
}

Measured memory_bytes: 62464
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

	int N, T;
	cin >> N >> T;
	vector<int> c, t;
	rep(i, 0, N) {
		int tmp_c, tmp_t;
		cin >> tmp_c >> tmp_t;
		c.push_back(tmp_c);
		t.push_back(tmp_t);
	}

	int rsl = 1e9;

	rep(i, 0, N) {
		if(t[i] <= T) rsl = min(rsl, c[i]);
	}
	if(rsl == 1e9) cout << "TLE" << endl;
	else cout << rsl << endl;

}


Measured memory_bytes: 256
// https://leetcode.com/problems/count-complete-tree-nodes/
#include <bits/stdc++.h>
using namespace std;


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

	
	string s; cin >> s;

	map<char,int> m {};

	for (char c : s)
		m[c]++;

	if (m.size() != 2)
		cout << "No";
	else
		cout << "Yes";

    return 0;
}

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

using namespace std;

const int N = 5e6 + 5, mod = 998244353;

long long powmod(long long b, long long p) {
  long long r = 1;
  for (; p; p >>= 1, b = b * b % mod)
    if (p & 1)
      r = r * b % mod;
  return r;
}

int fact[N], inv[N];

long long C(int n, int k) {
  if (k < 0 || n < k)
    return 0;
  return 1LL * (1LL * fact[n] * inv[k] % mod) * inv[n-k] % mod;
}

int main() {
  fact[0] = inv[0] = 1;
  for (int i = 1; i < N; ++i) {
    fact[i] = 1LL * i * fact[i-1] % mod;
  }
  inv[N-1] = powmod(fact[N-1], mod-2);
  for (int i = N-2; i > 0; --i) {
    inv[i] = inv[i+1] * 1LL * (i + 1) % mod;
  }
  int n;
  scanf("%d", &n);
  n /= 2;
  long long ans = powmod(3, 2 * n);
  long long sum = 0, pw2 = 2, pw = powmod(2, n), inv2 = inv[2];
  for (int a = 1; a <= n; ++a) {
    pw = (pw * inv2) % mod;
    sum = (sum + 1LL * C(n, n+1-a) * pw2) % mod;
    ans = (ans - sum * (C(n, a) * pw % mod)) % mod;
    pw2 = (pw2 * 2) % mod;
  }
  if (ans < 0)
    ans += mod;
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 39296
while True:
    n,m = map(int,input().split())
    if n==m==0: break
    
    taro = [int(input()) for i in range(n)]
    hanako = [int(input()) for i in range(m)]

    ans1 = []; ans2 = []
        
    for i in sorted(taro):
        for j in sorted(hanako):
            if sum(taro)-i+j == sum(hanako)-j+i:
                ans1.append(i); ans2.append(j)
    
    if len(ans1)==len(ans2)==0: print(-1)
    else: print(ans1[0],ans2[0])
        


Measured memory_bytes: 5720
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define PI (acos(-1))
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD = 1000000007;
// ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	ll weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
ll powMod(ll x, ll k, ll m) {//x^k (mod n)
	if (k == 0)     return 1;
	if (k % 2 == 0) return powMod(x*x % m, k/2, m);
	else            return x*powMod(x, k-1, m) % m;
}
int N;
int H,W;
int dif[85][85];
int dp[83][83][83*83]={0};
int main(){
	cin>>H>>W;
	rep(i,H)rep(j,W){
		cin>>dif[i][j];
	}
	rep(i,H)rep(j,W){
		int x;
		cin>>x;
		dif[i][j]-=x;
		dif[i][j]=abs(dif[i][j]);
	}
	dp[0][0][dif[0][0]]=1;
	rep(i,H)rep(j,W){
		int num=dif[i][j];
		if(i>0){
			rep(k,80*80-num)dp[i][j][k+num]|=dp[i-1][j][k];
			rep(k,80*80-num)dp[i][j][k]|=dp[i-1][j][k+num];
			rep(k,num)dp[i][j][k]|=dp[i-1][j][num-k];
		}
		if(j>0){
			rep(k,80*80-num)dp[i][j][k+num]|=dp[i][j-1][k];
			rep(k,80*80-num)dp[i][j][k]|=dp[i][j-1][k+num];
			rep(k,num)dp[i][j][k]|=dp[i][j-1][num-k];
		}
	}
	rep(k,80*80){
		if(dp[H-1][W-1][k]==1){
			cout<<k<<endl;
			return 0;
		}
	}
}



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

int max(int a,int b){
  if(a>b) return a;
  else return b;
}

int min(int a,int b){
  if(a>b) return b;
  else return a;
}


int main(){
  char s[100],t[100];
  int box[100]={};
  int flag=0;
  int i,j;
  char temp;

  scanf("%s",s);
  scanf("%s",t);
  if(strlen(s)<strlen(t)){
    for(i=0;i<strlen(s);i++){
      for(j=0;j<strlen(t);j++){
        if(s[i]==t[j]&&box[j]==0){
          box[j]=1;
          flag=1;
          break;
        }
        else flag=0;
      }
      if(flag==0)  break;
    } 
  }
  if(flag==1) printf("Yes\n");
  else{
    for(i=0;i<strlen(s)-1;i++){
      for(j=i+1;j<strlen(s);j++){
        if(s[i]>s[j]){
          temp=s[i];
          s[i]=s[j];
          s[j]=temp;
       }
      }
    }
    for(i=0;i<strlen(t)-1;i++){
      for(j=i+1;j<strlen(t);j++){
        if(t[i]<t[j]){
          temp=t[i];
          t[i]=t[j];
          t[j]=temp;
       }
      }
    }
    if(strcmp(s,t)<0) flag=1;
    if(flag) printf("Yes\n");
    else printf("No\n");
  }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define endl '\n'
#define uset unordered_set
#define umap unordered_map
#define all(var) var.begin(), var.end()
#define input freopen("input", "r", stdin)
#define output freopen("output", "w", stdout)
#define Fast ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL)
typedef unsigned long long ll;
using namespace std;

int dr[] = {0, 0, -1, +1, -1, -1, +1, +1};
int dc[] = {-1, +1, 0, 0, -1, +1, -1, +1};

const ll mod = 1e9+7;

int main(){
    int n; cin >> n;
    ll arr[n];
    ll pref[n];
    for(int i = 0; i < n; i++){
        cin >> arr[i];
        pref[i] = arr[i];
    }
    for(int i = 1; i < n; i++){
        pref[i] += pref[i-1];
    }
    ll ans = 0;
    for(int i = 0; i < n-1; i++){
        ans += ( arr[i] * ((pref[n-1]-pref[i])%mod) )%mod;
    }
    cout << ans%mod << endl;
}



Measured memory_bytes: 6716
#include<bits/stdc++.h> 
using namespace std;
int A[12],a[52],b[52],c[52],d[52];
int n,m,q,ans=-1;
void score()
{
	int sum=0;
	for(int j=1;j<=q;j++)
		if(A[b[j]]-A[a[j]]==c[j])
			sum+=d[j];
	ans=max(ans,sum);
}
void solve(int k,int q)
{
	for(int i=q;i<=m;i++){
		A[k]=i;
		if(k==n)	score();
		if(n==k&&i==m) break;
//		k++;
		if(k+1<=n)	solve(k+1,i);
	}
}
int main()
{  
	cin>>n>>m>>q;
	for(int j=1;j<=q;j++)
		cin>>a[j]>>b[j]>>c[j]>>d[j];
	solve(1,1);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
                    
                    
int main(){
   	int X;
    cin >> X;

    if(X >= 400 && X <= 599){
        cout << 8 << endl;
    } else if(X >= 600 && X <= 799) {
        cout << 7 << endl;
    } else if(X >= 800 && X <= 999) {
        cout << 6 << endl;
    } else if(X >= 1000 && X <= 1199) {
        cout << 5 << endl;
    } else if(X >= 1200 && X <= 1399) {
        cout << 4 << endl;
    } else if(X >= 1400 && X <= 1599) {
        cout << 3 << endl;
    } else if(X >= 1600 && X <= 1799) {
        cout << 2 << endl;
    } else if(X >= 1800 && X <= 1999) {
        cout << 1 << endl;
    }
            
}

Measured memory_bytes: 3632
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN = 200000;
char S[MAXN + 5];
int f[MAXN + 5];
int main() {
	scanf("%s", S + 1);
	int lenS = strlen(S + 1);
	for(int i=1;i<=lenS;i++)
		f[i] = -MAXN;
	f[1] = 1;
	for(int i=2;i<=lenS;i++) {
		f[i + 1] = max(f[i + 1], f[i - 2] + 2);
		if( S[i] != S[i - 1] )
			f[i] = max(f[i], f[i - 1] + 1);
	}
	printf("%d\n", max(f[lenS], f[lenS + 1] - 1));
}

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

using namespace std;
typedef long long ll;
int n;
ll k;
int niz[200005];
int dist[200005];

int bfs(int start){
    memset(dist,-1,sizeof(dist));
    dist[start]=0;
    queue<int>q;
    q.push(start);
    while(!q.empty()){
        int cur=q.front();
        q.pop();
        int next=niz[cur-1];
        if(dist[next]==-1){
            dist[next]=dist[cur]+1;
            q.push(next);
        }else{
            int cycle=dist[cur]+1-dist[next];
            int target;
            if(k<dist[next]){
                target=k;
            }else{
                target=(k-dist[next])%cycle +dist[next];
            }
            for(int i=1;i<=n;i++)
                if(dist[i]==target)
                    return i;
        }
    }
}

int main(){
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>niz[i];
    cout <<bfs(1);
}


Measured memory_bytes: 5192
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>

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

int main() {

	int N, H;
	int a[112345], b[112345];
	int amax = -1;

	scanf("%d%d", &N, &H);

	rep(i, N) {
		scanf("%d%d", &a[i], &b[i]);
		amax = max(a[i], amax);
	}

	long long last = 0;
	vector<long long> last_list;

	rep(i, N) {
		if (b[i] >= amax) {
			last += b[i];
			last_list.push_back(b[i]);
		}
	}
	if (last >= H) {
		sort(last_list.begin(), last_list.end(), greater<int>());
		int c = 0;
		rep(i, last_list.size()) {
			c += last_list[i];
			if (c >= H) {
				printf("%d\n", i + 1);
				return 0;
			}
		}
	}

	printf("%lld\n", (H - last - 1) / amax + 1 + (long long)last_list.size());

	return 0;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  int S[N];
  int C[N];
  for (int i = 0; i < M; ++i) {
    cin >> S[i] >> C[i];
    --S[i];
//    S[i] = N - S[i];
  }
  string num = "";
  for (int i = 0; i < N; ++i) {
    num += "*";
  }

  bool ok = true;

  for (int i = 0; i < M; ++i) {
    if (S[i] > N) {
      ok = false;
      break;
    }
    if (num[S[i]] != '*' &&
        num[S[i]] != C[i] + '0') {
      ok = false;
      break;
    }
    num[S[i]] = C[i] + '0';
  }
  if (num[0] == '0' &&
      N > 1) {
    ok = false;
  }

  for (int i = 0; i < N; ++i) {
    if (num[i] == '*') {
      if (N > 1 && i == 0) {
        num[i] = '1';
      } else {
        num[i] = '0';
      }
    }
  }

  if (!ok) {
    cout << -1 << endl;
  } else {
    cout << num << endl;
  }
  return 0;
}


Measured memory_bytes: 256
while True:
    h, w = map(int, input().split())
    if h == w == 0:
        break

    for i in range(h):
        for j in range(w):
            if (i + j) % 2 == 0:
                print('#', end='')
            else:
                print('.', end='')
        print()
    print()



Measured memory_bytes: 7008
import java.io.*;
import java.util.*;

public class Main {

    private static FastReader in = new FastReader(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    private static final long MOD = (long) 1e9 + 7;

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    private static void solve() {
        int n = in.nextInt();
        int k = in.nextInt();
        int[] h = in.nextIntArray(n);

        int[] minCost = new int[n];
        Arrays.fill(minCost, Integer.MAX_VALUE / 2);
        minCost[0] = 0;
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < Math.min(n, i + k + 1); j++) {
                minCost[j] = Math.min(minCost[j], minCost[i] + Math.abs(h[i] - h[j]));
            }
        }
        out.println(minCost[n - 1]);
    }

    // https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        // https://qiita.com/masakinpo/items/5f77f2a879578a85a0bb
        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


Measured memory_bytes: 33640
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define intarr(arr, n)  ll arr[n];  for (ll i = 0; i < n; i++)  cin >> arr[i]
#define inpvec(vec,n) for(ll i=0;i<n;i++){ll var;cin>>var;vec.push_back(var);}
#define ff first
#define ss second
#define pb push_back
#define mkp make_pair
#define vec vector<ll>
#define pi pair<ll,ll>
#define changeline cout<<endl
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define rev(i,a,b) for(ll i=a;i>=b;i--)
#define all(v) v.begin(),v.end()
#define mod2 998244353
#define NO cout << "NO" <<endl
#define YES cout << "YES" <<endl
#define mem(arr,val) memset(arr,val,sizeof(arr));
const ll mod=1e9+7;
#define piii 3.14159265358979323846264338327950
#define print(a, n, m)     for (ll i = n; i < m; i++) {  cout << a[i] << " "; }  cout << endl
#define con continue

bool prime(ll n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
bool isPerfectSquare(ll x) {   
  long double sr = sqrt(x); 
  return ((sr - floor(sr)) == 0); 
} 
bool subsequence_checker(string str1, string str2, ll m, ll n) 
{ 
    if (m == 0) return true; 
    if (n == 0) return false; 
    if (str1[m-1] == str2[n-1]) 
        return subsequence_checker(str1, str2, m-1, n-1); 
    return subsequence_checker(str1, str2, m, n-1); 
}
bool cmp(const pair<int,int> &a,  const pair<int,int> &b) 
{ 
    if(a.ff == b.ff)
        return a.ss < b.ss;
    return (a.ff > b.ff); 
}
//////////////////////////////////////////////////// Lets Do It ////////////////////////////////////////////////////////
int gcd(int p, int q){
if(p % q == 0)return q;
return gcd(q, p % q);
}

void solve()
{

    ll n,x,t;
    cin>>n>>x>>t;

    if(n<=x)
    {
        cout<<t;
        return;
    }

    if(n%x==0)
    {
        cout<<(n/x)*t;
        return;
    }

    cout<< ((n+x)/x)*t;


    return;
}
 
int main()
{

    IOS;
    ll t;
    //cin>>t;
    t=1;

    while(t--){
        solve();
        cout<<endl;
    }

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
} 



Measured memory_bytes: 3680
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
int main() {
	ll N, M, X; cin >> N >> M >> X;
	ll A, a, b;
	while (cin >> A) {
		(X > A) ? b++ : a++;
	}
	cout << min(a, b);
	return 0;
}

Measured memory_bytes: 256
def main():
    S = input()
    T = input()

    start = [-1] * 26
    goal = [-1] * 26

    for i in range(len(S)):
        a = ord(S[i]) - ord('a')
        b = ord(T[i]) - ord('a')

        if start[a] != -1 or goal[b] != -1:
            if start[a] != b or goal[b] != a:
                print('No')
                exit()
        
        start[a] = b
        goal[b] = a
    
    print('Yes')

main()

Measured memory_bytes: 41840
import java.util.*;

public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		
		if(s.charAt(2) == s.charAt(3) && s.charAt(4) == s.charAt(5))
			System.out.println("Yes");
		else
			System.out.println("No");
		//coffee
		
	}
}

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

int main() {
  int n;
  cin >> n;
  int panda[n];
  
  for(int i=0; i<n; i++){
    cin >> panda[i];
    
  }
  for(int j=n; j>0; j--){
    cout << panda[j-1];
    if(j!=1){
      cout << ' ';
    }
  }
  cout << endl;
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
#include <unistd.h>
#include <random>

using namespace std;
typedef long long int LL;
typedef long long int LLint;
typedef pair<int,int> intpair;
typedef pair<bool,bool> boolpair;
typedef pair<string,string> strpair;
typedef pair<LL,LL> LLpair;
typedef pair<double,double> doublepair;
typedef pair<float,float> floatpair;
typedef vector<int> intvector;
typedef vector<bool> boolvector;
typedef vector<string> strvector;
typedef vector<LL> LLvector;
typedef vector<double> doublevector;
typedef vector<float> floatvector;
#define wait(sec) usleep((sec) * 1000000)
#define ED return 0;
#define TEST cout << "OK" << endl;
#define UP(a,b) ((a+(b-1))/b)
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) LL(pow(x,y))
#define INF 999999999
const long long mod = 1000000007;

int main(){
    //    random_device rnd;
    //    mt19937 mt(rnd());
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B;
    cin >> A >> B;
    if(max(A,B) > 9){
        cout << -1 << endl;
    }
    else{
        cout << A*B << endl;
    }
}


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

const int mod = 1e9+7;
int row,col,dp[2][10005];
char grid[10005][10005];

void addSelf(int &x,int y)
{
    x += y;
    if(x >= mod)
        x -= mod;
}

void FuN()
{
    for(int i=1 ; i<=row ; i++){

        for(int j=1 ; j<=col ; j++)
            dp[i & 1][j] = 0;

        for(int j=1 ; j<=col ; j++){
            if(grid[i][j] == '#'){
                dp[i & 1][j] = 0;
                continue;
            }
            if(i == 1 && j == 1)
                dp[i & 1][j] = 1;
            else{
                addSelf(dp[i & 1][j] , dp[(i-1) & 1][j]);
                addSelf(dp[i & 1][j] , dp[i & 1][j-1]);
            }
        }
    }
    cout<<dp[row & 1][col]<<endl;
}

int main()
{
    cin>>row>>col;
    for(int i=1 ; i<=row ; i++){
        for(int j=1 ; j<=col ; j++)
            cin>>grid[i][j];
    }
    FuN();
    return 0;
}


Measured memory_bytes: 8512
n,m = map(int, input().split())

A = []
for i in range(n):
    A.append(list(map(int, input().split())))

b = []
for i in range(m):
    b.append(int(input()))

c = []

for i in range(n):
    tmp = 0
    for j in range(m):
        tmp += A[i][j] * b[j]
    c.append(tmp)

for i in range(n):
    print(c[i])

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

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

using namespace std;
using ll = long long;

int calc(int x, int y, int z) {
  return x * x + y * y + z * z + x * y + y * z + z * x; 
}


int main(void)
{
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int res = 0;
    for (int x = 1; x*x <= n; ++x) {
      for (int y = 1; y*y <= n; ++y) {
        for (int z = 1; z*z <= n; ++z) {
          if (calc(x,y,z) < i)
              continue;
          if (calc(x,y,z) == i)
            ++res;
            break;
        }
      }
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 3568
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N = readline().decode('utf-8').strip()
    print(N.count('2'))

if __name__ == '__main__':
    main()


Measured memory_bytes: 9032
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int S = sc.nextInt();
		int count = 0;
		for(int X = 0; X <= K; X++) {
			for(int Y = 0; Y <= K; Y++) {
				int Z = S - X - Y;
				if(Z >= 0 && Z <= K) count++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args){
		
		Scanner scan = new Scanner(System.in);
		
		String s = scan.nextLine();
		String p = scan.nextLine();
		scan.close();
		
		String ss = s + s;
		
		String strJudge = null;
		boolean isYes = false;
		for(int i = 0; i < ss.length(); i++){
			
			if(p.length() < ss.length()  - i){
				strJudge = ss.substring(i, i + p.length());
				//System.out.println(i + ":strJudge:" + strJudge);
			}
			
			if(p.equals(strJudge)){
				System.out.println("Yes");
				isYes = true;
				break;
			}			
		}
		if(!isYes){
			System.out.println("No");
		}
	}

}

Measured memory_bytes: 17196
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    int n,d;
    cin>>n>>d;
    int x[n][d];
    for(int i=0;i<n;i++){
        for(int j=0;j<d;j++){
            cin>>x[i][j];
        }
    }
    int ans=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            int tmp = 0;
            for(int k=0;k<d;k++){
                tmp+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
            }
            if(sqrt(tmp)-(int)sqrt(tmp)<=0.00001){
                ans++;
            }
        }
    }
    cout<<ans<<endl;





    return 0;
}


Measured memory_bytes: 256
while True:
    count = 0
    n, x = map(int, input().split())
    if n == 0 and x == 0:
        exit()
    for i in range(1, n+1):
        for j in range(i+1, n+1):
            for k in range(j+1, n+1):
                if i+j+k == x:
                    count += 1
    print(count)



Measured memory_bytes: 5596
#include <stdio.h>
#define N 100
#define NOT_VISITED 0
#define SEMI_VISITED 1
#define VISITED 2

int n, M[N][N];
int status[N], d[N], f[N], tt;

void dfs_visit(int u) {
    int v;
    status[u] = SEMI_VISITED;
    d[u] = ++tt;
    for (v = 0; v < n; v++) {
        if (M[u][v] == 0) continue;
        if (status[v] == NOT_VISITED) {
            dfs_visit(v);
        }
    }
    status[u] = VISITED;
    f[u] = ++tt;
}

void dfs() {
    int u;
    for (u = 0; u < n; u++) status[u] = NOT_VISITED;
    tt = 0;

    for (u = 0; u < n; u++) {
        if (status[u] == NOT_VISITED) dfs_visit(u);
    }
    for (u = 0; u < n; u++) {
        printf("%d %d %d\n", u + 1, d[u], f[u]);
    }    
}

int main(void)
{
    int u, v, k, i, j;

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

    for (i = 0; i < n; i++) {
        scanf("%d %d", &u, &k);
        u--;
        for (j = 0; j < k; j++) {
            scanf("%d", &v);
            v--;
            M[u][v] = 1;
        }
    }
    
    dfs();

    return 0;
}


Measured memory_bytes: 2100
#include <stdio.h>
#include <string.h>
#include <vector>
#include <numeric>
#include <algorithm>
#include <functional>
#include <math.h>

using namespace std;


int main() {

  char tab[10];
  scanf("%s", &tab);

  printf("%s", tab[1] == 'B' ? "ARC" : "ABC");

  return 0;
}


Measured memory_bytes: 1732
#!/usr/bin/python3
# -*- coding:utf-8 -*-

import numpy

def main():
  n, d = map(int, input().strip().split())
  xs = numpy.array([[list(map(int, input().strip().split()))] for _ in range(n)])
  count = 0
  for i in range(n-1):
    for j in range(i+1, n):
      l2n = numpy.linalg.norm(xs[i] - xs[j])
      if l2n % int(l2n) == 0:
        count += 1
  print(count)

if __name__=='__main__':
  main()



Measured memory_bytes: 14208
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b
long double f(long double a,int b){
  if(b==0)return 1;
  if(b%2==0){
    long double t=f(a,b/2);
    return t*t;
  }
  return f(a,b-1)*a;
}

signed main(){
  cout << fixed << setprecision(10);
	int n; cin>>n;
    int k; cin>>k;
  int c=0;
  long double ans=0;
  long double a=0;
  if(n>=k){
    a+=(long double)(n-k+1)/n;
   // cout<<n-k+1<<" "<<n<<endl;
   // cout<<"a:"<<a<<endl;
  }
  rep(i,1,n+1){
    if(i>=k)break;
    int j=i;
    int cnt=0;
    while(j<k){
      j*=2;
      cnt++;
    }
    //cout<<cnt<<endl;
    ans+=f(0.5,cnt)/n;
  }
  cout<<ans+a<<endl;
  	
	
      
      
 	
  
	
	
	return 0;
}

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

using namespace std;

typedef long long ll;
bool is_prime[10000001];

void seive(int n){
	int i,j,p=0;
	fill(is_prime,is_prime+n+1,true);
	is_prime[0]=is_prime[1]=false;
	for(i=2;i*i<=n;i++){
		if(is_prime[i]){
			for(j=2*i;j<=n;j+=i)is_prime[j]=false;
		}
	}
}

int main(void){
	int a,n;
	seive(10000000);
	while(1){
		cin >> n;
		if(n==0)break;
		while(1){
			if(is_prime[n]==true && is_prime[n-2]==true && is_prime[n-6]==true && is_prime[n-8]==true)break;
			n--;
		}
		cout << n << endl;
	}
	return 0;
}

Measured memory_bytes: 10000
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T> 
void print(vector<vector<T>> &x) {
	int n = x.size();
	rep(i,n) {
		rep(j,4) {
			cout << x[i][j] << " ";
		}
		cout << endl;
	}
}

int main(int argc, char const *argv[]) {
	int n,m; cin>>n>>m;
	ll sum = 0;
	vector<ll> a(n);
	vector<vector<ll>> b(n, vector<ll>(40));
	rep(i,n) cin>>a[i], sum+=a[i];
	rep(i,n) {
		rep(j,40) {
			ll tmp = powl(2,j+1);
			ll tap = powl(2,j);
			b[i][j] = (a[i]/tap)-(a[i]/tmp);
			if (a[i]/tmp == 0) break;
		}
	}
	// print(b);
	priority_queue<ll> pq;
	rep(i,n) {
		rep(j,40) {
			pq.push(b[i][j]);
		}
	}
	ll ans = 0ll;
	int cnt = 0;
	while (!pq.empty()) {
		++cnt;
		ll t = pq.top(); pq.pop();
		ans += t;
		if (cnt == m) break;
	}

	cout << max(sum-ans,0ll) << endl;
	return 0;
}


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

using namespace std;

const int Maxn = 2e5+7;

int n;
int a[Maxn];

int main()
{
    cin >> n;
    for(int i = 0; i < n; ++i) cin >> a[i];
    int l = 1, r = n;
    while(l < r)
    {
        int mid = (l+r)>>1, flag = 0;
        vector<pair<int, int> > v;
        for(int i = 1; i < n; ++i)
            if(a[i] <= a[i-1])
            {
                if(mid <= 1) { flag = 1; break; }
                while(v.size() && v.back().first >= a[i])
                    v.pop_back();
                int cur = a[i]-1;
                while(cur >= 0 && v.size() && v.back().first == cur && v.back().second == mid-1)
                    v.pop_back(), cur--;
                if(cur < 0) { flag = 1; break; }
                if(v.empty() || v.back().first < cur)
                    v.push_back(make_pair(cur, 1));
                else v.back().second++;
            }

        if(flag) l = mid+1;
        else r = mid;
    }
    cout << l << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
#define ll long long
 
void init();
void solve();
 
#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
 
#ifdef LOCAL
#define lcout(a) cout << a;
#define lcoutln(a) cout << a << endl;
#define lcerr(a) cerr << a;
#define lcerrln(a) cerr << a << endl;
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif
 
#define MOD 1000000007
 
signed main()
{
	init();
	solve();
}

string s;
int l;

void init()
{
  cin >> s;
  l = s.length();
}
 
void solve()
{
  rep(i, l-1) {
    if (s[i] == 'A' && s[i+1] == 'C') {
      PRINT(1);
      return;
    }
  }
  PRINT(0);
}

Measured memory_bytes: 256
ls = input().split()
l = [int(i) for i in ls]


b = l[1]+l[2]
n = int(l[0]/b)
a = n*l[1]
if l[0]%b>=l[1]:
    a+=l[1]
else:
    a+=l[0]%b
    
print(int(a))

Measured memory_bytes: 3060
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;

int main(){
  ll N,A,B,ans;
  cin>>N>>A>>B;
  if(A>B) ans=0;
  else if(N>=2) ans=(N-2)*(B-A)+1;
  else if(N==1){
    if(A==B) ans=1;
    else ans=0;
  }
  cout<<ans<<endl;
}


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

const int MAX_DW=11;

int d,w,ans,hi,lo,cnt;
vector<vector<int>> e(MAX_DW,vector<int>(MAX_DW));

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> d >> w,d){
        for (int i=0;i<d;++i)
            for (int j=0;j<w;++j)
                cin >> e[i][j];
        ans=0;
        for (int i=0;i<d;++i){
            for (int j=i+2;j<d;++j){
                for (int k=0;k<w;++k){
                    for (int l=k+2;l<w;++l){
                        hi=0,lo=10,cnt=0;
                        for (int x=i;x<=j;++x){
                            for (int y=k;y<=l;++y){
                                if (x==i||x==j||y==k||y==l){
                                    lo=min(lo,e[x][y]);
                                } else hi=max(hi,e[x][y]);
                            }
                        }
                        if (hi>=lo) continue;
                        for (int x=i+1;x<j;++x){
                            for (int y=k+1;y<l;++y){
                                cnt+=lo-e[x][y];
                            }
                        }
                        ans=max(ans,cnt);
                    }
                }
            }
        }
        cout << ans << '\n';
    }
}


Measured memory_bytes: 3136
#include <stdio.h>
int main() {
    char S[4];
    scanf("%s", &S);
    if(S[0] != S[1]) {
        printf("Yes");
    }
    else if (S[1] != S[2]){
        printf("Yes");
    }
    else {
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 3072
while True:
	H ,W = map(int,input().split())
	if H * W == 0 : 
		break
	else:
		a = '#'*W
		a = list(a)
		b = '.'*W
		b = list(b)
		for i in range(W):
			if not(i % 2):
				a[i] = '.'
				b[i] = '#'
	for i in range(H):
		if i % 2 :
			print("".join(a))
		else:
			print("".join(b)) 
	print()


Measured memory_bytes: 5616
#include <iostream>

using namespace std;
typedef long long ll;
int main() {
  ll n;
  cin >> n;

  ll two = 0;
  ll five = 0;

  ll tmp = 2;

  if(n & 1) {
    cout << 0 << endl;
    return 0;
  }
  while(n / tmp > 0) {
    two += n / tmp;
    tmp *= 2;
  }
  tmp = 5;

  while(n / (tmp * 2) > 0) {
    five += n / (tmp * 2);
    tmp *= 5;
  }
  cout << min(two,five) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=1<<17,mo=1e9+7;
int n,x,y,z,ans,dp[41][N];
signed main()
{
	scanf("%d%d%d%d",&n,&x,&y,&z);
	dp[0][0]=1;
	int ct=(1<<z-1)|(1<<y+z-1)|(1<<x+y+z-1);
	int state=(1<<x+y+z)-1,now;
	for(int i=1;i<=n;i++)
		for(int s=0;s<=state;s++){
			if(dp[i-1][s]==0) continue;
			for(int k=1;k<=10;k++){
				now=(s<<k)|(1<<k-1);
				now&=state;
				if((now&ct)!=ct)
					dp[i][now]=(dp[i][now]+dp[i-1][s])%mo;
		}		
	}
	ans=1;
	for(int i=1;i<=n;i++)
		ans=ans*10%mo;
	for(int i=0;i<=state;i++)
		ans=(ans-dp[n][i]+mo)%mo;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 40192