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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)


typedef long long ll;
typedef unsigned long long int llt;

const int N = 1e5 + 10;

vector<int> g[N];
bool viss[N];
int vis[N];

void dfs(int curr, int par)
{
  for(auto x: g[curr])
    if(x != par)
      dfs(x, curr);
}

void dfs1(int curr, int par)
{
  viss[curr] = 1;
  for(auto x: g[curr])
    if(!viss[x])
      dfs1(x, curr);
}

void dfs2(int curr, int par, int num)
{
  vis[curr] = num;
  for(auto x: g[curr])
    if(vis[x] == 0)
      dfs2(x, curr, num);
}

ll fxor(ll n)
{
  if(n < 0) return 0;
  if(n % 4 == 3) return 0;
  else if(n % 4 == 0) return n;
  else if(n % 4 == 1) return n^(n-1);
  else if(n%4 == 2) return n^(n-1)^(n-2);
}

llt ppow(llt x, llt y)
{
  llt res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%M;
    y = y >> 1;
    x = (x * x)%M;
  }
  return res;
}

llt factdp[N];
llt fact(llt x)
{
  if(x == 0) return 1;
  if(x == 1) return 1;
  if(factdp[x] != -1) return factdp[x];
  return factdp[x] = (x*fact(x-1))%M;
}

string ans ="";
void convert10tob(llt N, int b)
{
     if (N == 0)
        return;
     int x = N % b;
     N /= b;
     if (x < 0)
        N += 1;
     convert10tob(N, b);
     ans += to_string(x);
     return;
}

llt convertstrtob(string a, int b)
{
  llt aa = 0;
  llt mul = 1;
  for(int i=a.length()-1; i>=0; i--)
  {
    int curr = a[i] - '0';
    aa += (curr * mul);
    mul *= b;
  }
  return aa;
}
string x[4] = {"dream", "dreamer", "erase", "eraser"};

bool findans(string s, int curr)
{
  int i = 0;
  while(i < s.length())
  {
    if(s[i] == 'd')
    {
      string ss = "dream";
      rep(j, 0, ss.length()){
        if(ss[j] != s[i])
          return 0;
        i++;
      }
      if(i == s.length()) return 1;
      if(s[i] == 'e')
      {
        if(s[i+1] == 'r')
          if(i+2 == s.length() || s[i+2] != 'a')
            i += 2;
      }
    }
    else if(s[i] == 'e')
    {
      string ss = "erase";
      rep(j, 0, ss.length())
      {
        if(ss[j] != s[i]) return 0;
        i++;
      }
      if(i == s.length()) return 1;
      if(s[i] == 'r') i++;
    }
    else
    {
      return 0;
    }
  }
  return 1;
}

int main()
{
  string s;
  cin>>s;
  if(findans(s, 0)) puts("YES");
  else puts("NO");
  return 0;
}


Measured memory_bytes: 2816
#include <stdio.h>

int main(void){
	int n;
	char s[110];
	int i,ans=0;
	scanf("%d", &n);
	for (i = 0; i < n; i++){
		scanf("%c", &s[i]);

	}
	for (i = 0; i < n; i++){
		if (s[i] == 'Y'){
			printf("Four\n");
			return 0;
		}
	}
	printf("Three\n");
	return 0;
}




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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const ll INF = LLONG_MAX;

int main() {
  ll n, ans = 0;
  cin >> n;
  ll a[n][n], dp[n][n];
  rep(i, n) rep(j, n) cin >> a[i][j], dp[i][j] = a[i][j];

  for (int k = 0; k < n; ++k) {
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        if (i == j || i == k || k == j || dp[i][k] == INF || dp[k][j] == INF)
          continue;
        if (a[i][j] == dp[i][k] + dp[k][j]) {
          dp[i][j] = INF;
        } else if (a[i][j] > dp[i][k] + dp[k][j]) {
          cout << -1 << endl;
          return 0;
        }
      }
    }
  }

  rep(i, n) rep(j, n) if (dp[i][j] != INF) ans += dp[i][j];

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

Measured memory_bytes: 1664
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
 
#include<bits/stdc++.h>
 
using namespace std;
#define ll int
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define ull unsigned long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ff first
#define ss second
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0); 
#define nl "\n"
#define sz(a) (int)(a).size() 
#define all(a) (a).begin(),(a).end()
#define fl(a,x) memset(a,x,sizeof(a));
#define pt(a,x) cout << get<x>(a) << " " ;  
#define mt make_tuple 
#define vec vector
 
#define int long long 
 
const int mod = (int) 1e9 + 7 ;
const int MOD = (int) 998244353 ;
const int INF = (int) 1e18 ;
 
typedef vector<int> vii;
typedef pair<int,int> pii;
typedef vector<pii> vpi;
typedef vector<vector<int> > vv;
 
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
 
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

void solve(int test) {
	int n,k ; cin >> n >> k ;
	int a[n]; rep(i,0,n) cin >> a[i] ;

	rep(i,k,n) {
		if(a[i] > a[i-k]) cout << "Yes\n";
		else cout << "No\n"; 
	}
}
 
int32_t main() {
 
  

    fast;
	int t=1;
	// cin>>t;
	rep(i,1,t+1) {
		solve(i) ;
	}
 
	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

Measured memory_bytes: 5212
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cassert>
#include<ctime>
using namespace std;

#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define absd(x) (x<0?-(x):x)
#define pow2(x) ((x)*(x))
#define rep(i,n) for(int i=0; i<n; ++i)
#define repr(i,n) for(int i=n-1; i>=0; --i)
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define replr(i,s,n) for(int i=n; i>=s; --i)
#define repf(i,s,n,j) for(int i=s; i<=n; i+=j)
#define repe(e,obj) for(auto e : obj)

#define SP << " " <<
#define COL << " : " <<
#define COM << ", " <<
#define ARR << " -> " <<
#define PNT(STR) cout << STR << endl
#define POS(X,Y) "(" << X << ", " << Y << ")"
#define DEB(A) " (" << #A << ") " << A
#define DEBREP(i,n,val) for(int i=0; i<n; ++i) cout << val << " "; cout << endl
#define ALL(V) (V).begin(), (V).end()
#define INF 1000000007
#define INFLL 1000000000000000007LL
#define EPS 1e-9

typedef unsigned int uint;
typedef unsigned long ulong;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define P_TYPE int
typedef pair<P_TYPE, P_TYPE> P;
typedef pair<P, P_TYPE> PI;
typedef pair<P_TYPE, P> IP;
typedef pair<P, P> PP;
typedef priority_queue<P, vector<P>, greater<P> > pvqueue;

#define SZ 53
int used[SZ][SZ][SZ][SZ];
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};

char ml[SZ][SZ], mr[SZ][SZ];

int main() {
  int w, h;
  while(cin >> w >> h && w+h) {
    int lx, ly, rx, ry;
    rep(i, h) {
      rep(j, w) {
        cin >> ml[i][j];
        if(ml[i][j] == 'L') {
          lx = j; ly = i;
        }
      }
      rep(j, w) {
        cin >> mr[i][j];
        if(mr[i][j] == 'R') {
          rx = j; ry = i;
        }
      }
    }
    used[ly][lx][ry][rx] = 1;
    rep(i, h) rep(j, w) rep(k, h) rep(l, w) used[i][j][k][l] = 0;
    queue<PP> que;
    que.push(PP(P(lx, ly), P(rx, ry)));
    bool ok = false;
    while(!que.empty()) {
      PP pp = que.front(); que.pop();
      P &lp = pp.first, &rp = pp.second;
      int lx = lp.first, ly = lp.second, rx = rp.first, ry = rp.second;
      rep(k, 4) {
        int x = dx[k], y = dy[k];
        int n_lx = lx + x;
        if(!(0 <= n_lx && n_lx < w)) n_lx = lx;
        int n_ly = ly + y;
        if(!(0 <= n_ly && n_ly < h)) n_ly = ly;
        if(ml[n_ly][n_lx] == '#') {
          n_lx = lx; n_ly = ly;
        }
        int n_rx = rx - x;
        if(!(0 <= n_rx && n_rx < w)) n_rx = rx;
        int n_ry = ry + y;
        if(!(0 <= n_ry && n_ry < h)) n_ry = ry;
        if(mr[n_ry][n_rx] == '#') {
          n_rx = rx; n_ry = ry;
        }
        if(ml[n_ly][n_lx] == '%' || mr[n_ry][n_rx] == '%') {
          if(ml[n_ly][n_lx] == '%' && mr[n_ry][n_rx] == '%') {
            ok = true;
          }
          continue;
        }
        if(!used[n_ly][n_lx][n_ry][n_rx]) {
          used[n_ly][n_lx][n_ry][n_rx] = 1;
          que.push(PP(P(n_lx, n_ly), P(n_rx, n_ry)));
        }
      }
    }
    cout << (ok ? "Yes" : "No") << endl;
  }
  return 0;
}

Measured memory_bytes: 31448
n=int(input())
h=[int(i) for i in input().split()]
if n==1:
    print("Yes")
    exit()
hi,hn=h[0],h[1]
if hi-hn>1:
    print("No")
    exit()
elif hi-hn>0:
    hi-=1
if n==2:
    print("Yes")
    exit()
for i in range(n-1):
    if hi>hn:
        print("No")
        exit()
    elif hi<hn:
        hn-=1
    if n-i>2:
        hi=hn
        hn=h[i+2]
print("Yes")

Measured memory_bytes: 14396
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

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


i64 x,y;

i64 extgcd(i64 a, i64 b, i64 &p, i64 &q){
	if(b == 0){
		p = 1;
		q = 0;
		return a;
	}
	i64 c = extgcd(b, a%b, q, p);
	q -= a/b * p;
	return c;
}
inline i64 mod(i64 a, i64 m) {
    return (a % m + m) % m;
}
i64 modinv(i64 a, i64 m) {
    i64 x, y;
    extgcd(a, m, x, y);
    return mod(x, m);
}
i64 fract(i64 x, i64 y, i64 mod){
	return x*modinv(y, mod) % mod;
}

const int MAX = 202020, MOD = INF;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long C(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
	cin >> x >> y;
	
	COMinit();
	
	i64 ans = fract(1,2,INF), cnt = 1;
	for(int i = 0; i < x+y; i++){
		cnt = mod(cnt*2, INF);
		i64 X = C(i-1, x-1), Y = C(i-1, y-1);
		ans += (fract(Y, cnt, INF) - fract(X, cnt, INF));
		ans = mod(ans, INF);
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 6912
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
llint gcd(llint a, llint b) {
	if (b > a)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
llint Tow(int m,int n) {//2のn乗
	if (n == 0)return 1;
	llint x = Tow(m,n / 2);
	x *= x;
	if (n % 2 == 1)x *= m;
	return x;
}
ll max(ll a, ll b) {
	if (a < b)return b;
	else return a;
}

int main() {
	int n;
	cin >> n;
	hei(double) p(n);
	rep(i, 0, n)cin >> p[i];
	whei(double) dp(n + 1, hei(double)(n + 1, 0));
	dp[0][0] = 1;
	rep(i, 0, n) {
		rep(j, 0, i + 1) {
			dp[i+1][j + 1] += dp[i][j] * p[i];
			dp[i+1][j] += dp[i][j] * (1 - p[i]);
		}
	}
	double ans = 0;
	rep(i, (n + 1) / 2, n + 1)ans += dp[n][i];
	cout << keta(9) << ans << endl;
	return 0;
}

Measured memory_bytes: 70784
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<string>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<iostream>
#include<algorithm>
#include<unordered_map>
#include<unordered_set>
#define PI acos(-1)
#define pb push_back
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
#define dd(x) cout<<#x<<" = "<<x<<","
#define de(x) cout<<#x<<" = "<<x<<"\n"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int N=1e5+5;
ll a[N];
ll mx=1e18;
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
		if(a[i]==0){
			printf("0");
			return 0;
		}
	}
	ll sum=a[1];
	for(int i=2;i<=n;i++){
		if(1.0*sum*a[i]>mx+10){
			printf("-1");
			return 0;
		}
		else{
			sum*=a[i];
			if(sum>mx){
				printf("-1");
				return 0;
			}
		}
	}
	printf("%lld",sum);
}


Measured memory_bytes: 4500
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
long long mmin(long long &a,long long b) {
	a = min(a, b);
	return a;
}
long long mmax(long long &a,long long b) {
	a = max(a, b);
	return a;
}
int nibu(vector<int> &v, int tan) {
	int up = v.size()-1;
	int lo = 0;
	if (tan <= v[0]) {
		return 0;
	}
	while (up - lo > 1) {
		int mi = (up + lo) / 2;
		if (tan <= v[mi]) {
			up = mi;
		}
		if (v[mi] < tan) {
			lo = mi;
		}
	}
	return up;
}
int ne(int &i, int &j, int k, int ty) {
	int di = 0; int dj = 0;
	if (k % 3 == 1) {
		dj = 1;
	}
	else if (k == 2) {
		dj = -2;
	}
	else if (k == 3) {
		di = 1;
	}
	else if (k == 5) {
		di = -2;
	}
	else {
		dj = -1;
	}
	if (ty == 1) {
		dj = -dj;
	}
	i += di;
	j += dj;
	return 0;
}
int main() {
	int w, h;
	cin >> w >> h;
	vector<vector<int> > ta(h, vector<int>(w));
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> ta[i][j];
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (ta[i][j] == 0) {
				vector<vector<int> > qt = ta;
				qt[i][j] = 1;
				vector<int> nei(h*w);
				vector<int> nej(h*w);
				nei[0] = i;
				nej[0] = j;
				int up = 1;
				int lo = 0;
				int da = 0;
				while (up != lo and da == 0) {
					int qup = up;
					for (int in = lo; in < up and da == 0; in++) {
						int pi = nei[in];
						int pj = nej[in];
						if (0 < pi and pi < h - 1) {
							if (0 < pj and pj < w - 1) {
								int ty = (pi+1) % 2;
								for (int k = 0; k < 6; k++) {
									ne(pi, pj, k+1, ty);
									if (qt[pi][pj] == 0) {
										nei[qup] = pi;
										nej[qup] = pj;
										qup++;
										qt[pi][pj] = 1;
									}
								}
							}
							else {
								da = 1;
							}
						}
						else {
							da = 1;
						}
					}
					lo = up;
					up = qup;
				}
				if (da == 0) {
					ta = qt;
				}
			}
		}
	}
	vector<vector<int> > ht(h + 2, vector<int>(w + 2,0));
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			ht[i + 1][j + 1] = ta[i][j];
		}
	}
	h += 2;
	w += 2;
	int ans = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (j < w - 1) {
				if (ht[i][j] + ht[i][j + 1] == 1) {
					ans++;
				}
			}
			int x = j - 1+i % 2;
			if (x >= 0 and i < h - 1) {
				if (ht[i][j] + ht[i + 1][x] == 1) {
					ans++;
				}
			}
			int y = j + i % 2;
			if (y < w and i < h - 1) {
				if (ht[i][j] + ht[i + 1][y] == 1) {
					ans++;
				}
			}
		}
	}
	cout << ans << endl; 
}


Measured memory_bytes: 3280
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>

using namespace std;

void b_bite_eating(void) {
	int n, l;
	cin >> n >> l;

	int taste;
	int sum = 0;
	int taste_abs_min = 10000;
	for (int i = 1; i <= n; i++) {
		taste = l + i - 1;
		sum += taste;

		if (abs(taste_abs_min) > abs(taste)) taste_abs_min = taste;
	}

	cout << sum - taste_abs_min << endl;
}

int main()
{
    b_bite_eating();

    return 0;
}


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

#pragma warning(disable:4996)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")

 
using namespace std;
 
#define int long long
#define ll long long
#define vi vector <int>
#define vii vector <pair<int,int> >
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repD(i,a,b) for (int i=a;i>b;i--)
#define pb push_back
#define pii pair <int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define MOD 1000000007
#define PI 3.14159265359
 
#define deb(x) {x}
#ifndef local
	#define deb(x) ;
#endif
///----------------------------------------------------------------------------------

int n,m;
string a,b;
map<char,vi> pos;

void solve()
{
	cin>>n>>a;
	if (n<3200)cout<<"red";else cout<<a;
}

signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);
 	
 	#ifdef local
    //freopen("input.txt","r",stdin);
    ///freopen("output.txt","w",stdout);
    clock_t qwertyuiop = clock();
    #endif
 
 	int t=1;
    //cin>>t;
    
    rep(a,0,t)
    {
        ///cout<<"Case #"<<a+1<<": ";
        solve();
	}
	
    #ifdef local
    {qwertyuiop = clock() - qwertyuiop;double time_taken = ((double)qwertyuiop)/CLOCKS_PER_SEC;cerr<<fixed<<setprecision(5)<<"\n\nTime Taken : "<<time_taken<<" seconds\n";}
	#endif
}



Measured memory_bytes: 256
import java.util.*;

public class Main
{
    private static final int field_size = 8;
    private static final int chein_length = 2;

    private static final int[] xdir = {0, 1, 0, -1};
    private static final int[] ydir = {1, 0, -1, 0};

    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int n = Integer.parseInt(sc.nextLine());

	for(int i = 1; i <= n; ++i){
	    String blank_line = sc.nextLine();

	    char[][] field = new char[field_size][];
	    for(int j = 0; j < field_size; ++j){
		field[j] = sc.nextLine().toCharArray();
	    }

	    int x = Integer.parseInt(sc.nextLine()) - 1;
	    int y = Integer.parseInt(sc.nextLine()) - 1;

	    simulationDfs(field, x, y, 0, 0);

	    System.out.printf("Data %d:\n", i);
	    printField(field);
	}
    }

    private static void simulationDfs(char[][] field, int x, int y, int bomb, int dir){
	if(y < 0 || x < 0 || y > 7 || x > 7){
	    return;
	}

	if(field[y][x] == '1'){
	    field[y][x] = '0';

	    for(int i = 0; i < 4; ++i){
		simulationDfs(field, x+xdir[i], y+ydir[i], chein_length, i);
	    }
	}

	if(bomb > 0){
	    simulationDfs(field, x+xdir[dir], y+ydir[dir], bomb-1, dir);
	}
    }

    private static void printField(char[][] field){
	for(int i = 0; i < field_size; ++i){
	    for(int j = 0; j < field_size; ++j){
		System.out.print(field[i][j]);
	    }
	    System.out.println();
	}
    }
}

Measured memory_bytes: 17364
module Main where

import Control.Applicative
import Control.Exception (assert)
import Control.Monad

data Test = Test Integer Integer Integer Integer
          deriving (Show, Eq)
data Result = Yes | No
            deriving (Show, Eq)

solve :: Test -> Result
solve (Test a b c d) | d < b = No
                     | a < b = No
                     | c >= b = Yes
                     | k1 < n && a1 > c = No
                     | k2 < n && a2 > c = No
                     | otherwise = Yes
    where a' = a `mod` b
          g = b `gcd` d
          n = b `div` g

          k1 = (b - 1 - a') `div` g
          k2 = n - 1

          a1 = (a + k1 * g) `mod` b
          a2 = (a + k2 * g) `mod` b
          -- (a' + k * g) mod b <= c, where k in [0, n).
          -- For all k: k * g < b, a' < b. Therefore, a' + k * g < 2 * b
          -- a' + k * g < b => a' + k * g + 1 <= b => k <= (b - 1 - a') `div` g

tests = [Test 9 7 5 9,
         Test 9 7 6 9,
         Test 14 10 7 12,
         Test 14 10 8 12,
         Test 14 10 9 12,
         Test 14 10 7 11,
         Test 14 10 8 11,
         Test 14 10 9 11,
         Test 9 10 5 10,
         Test 10 10 5 10,
         Test 11 10 5 10,
         Test 16 10 5 10,
         Test 1000000000000000000 17 14 999999999999999985,
         Test 1000000000000000000 17 15 999999999999999985] :: [Test]

main :: IO ()
main = do
  numTests <- read <$> getLine
  replicateM_ numTests $ do
         [a, b, c, d] <- map read . words <$> getLine
         print $ solve (Test a b c d)


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

int main(void){
	int n;
	cin>>n;
	int a[n+1];
	a[0] = 0;
	for(int i=1; i<=n; i++){
		a[i] = a[i-1]+1;
		for(int j=6; j<=i; j*=6){
			a[i] = min(a[i], a[i-j]+1);
		}
		for(int j=9; j<=i; j*=9){
			a[i] = min(a[i], a[i-j]+1);
		}
	}
	cout<<a[n]<<endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
using namespace std;
int main(void){
    int n;
    cin>>n;
    vector<double> v(n);
    for(int i=0; i<n; i++){
        cin>>v.at(i);
    }
    sort(v.begin(), v.end());
    while(v.size()>1){
        v.at(0)=(v.at(0)+v.at(1))/2;
        v.erase(v.begin()+1);
    }
    cout << fixed << setprecision(10) << v.at(0) << endl;
}


Measured memory_bytes: 764
#include <cstdio>
#include <map>
#include <cstring>
#include <algorithm>
using namespace std;
#define mst(a,b) memset((a),(b),sizeof(a))
#define rush() int T;scanf("%d",&T);while(T--)

typedef long long ll;
const int maxn = 100005;
const ll mod = 998244353;
const int INF = 0x3f3f3f3f;
const double eps = 1e-6;

int main()
{
    int n,m;
    while(~scanf("%d%d",&n,&m))
    {
        int ans=(n-1)*(m-1);
        printf("%d\n",ans);
    }
}


Measured memory_bytes: 256
import copy
import collections
n = int(input())

a_list = list(map(str, input().split()))
c = collections.Counter(a_list)

tmp_list = []

ans = 0
for j in c:
    tmp = c[str(j)]
    #print('tmp')
    #print(tmp)
    ans += (tmp-1)*tmp/2

#print('ttt')
#print(ans)


for k in range(n):
    #ans = 0
    #tmp = c[str(a_list[k])] # a_list[k]の数の個数
    #print('tmp')
    #print(tmp)
    #print(c[str(a_list[k])]-1)
    #ans -= c[str(a_list[k])]-1
    #if str(a_list[k]) == j:
    #    tmp = c[str(a_list[k])]-1
    #else:
    #    tmp = c[str(j)]

    #ans += (tmp-1)*tmp/2

    print(int(ans - (c[str(a_list[k])]-1)))




Measured memory_bytes: 26916
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;
typedef vector<VD> VVD;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const int INF = 1e8;

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    REP(i,h) cin >> s[i];
    P pma(-INF, -INF), pmi(INF, INF), nma(-INF, INF), nmi(INF, -INF);
    REP(i,h) REP(j,w){
        if (s[i][j] != 'B') continue;
        if (i + j > pma.first + pma.second) pma = P(i, j);
        if (i + j < pmi.first + pmi.second) pmi = P(i, j);
        if (i - j > nma.first - nma.second) nma = P(i, j);
        if (i - j < nmi.first - nmi.second) nmi = P(i, j);
    }
    int ans = 0;
    REP(i,h) REP(j,w){
        if (s[i][j] != 'B') continue;
        chmax(ans, abs(i - pma.first) + abs(j - pma.second));
        chmax(ans, abs(i - pmi.first) + abs(j - pmi.second));
        chmax(ans, abs(i - nma.first) + abs(j - nma.second));
        chmax(ans, abs(i - nma.first) + abs(j - nma.second));
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3244
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n:usize,
        k:usize
    }
    let mut ans:f64 = 0.0;
    for i in 1..(n+1) {
        if i >= k {
            ans+=1.0;
            continue;
        }
        let mut s = i;
        let mut ind:i32 = 0;
        loop {
            s*=2;
            ind+=1;
            // println!("s {}", s);
            if s >=k {
                break;
            }
        }
        // println!("{}", ans);
        // let deb = 1.0 / (2f64.powi(ind) as f64);
        // println!("deb {}", deb);
        ans += 1.0 / (2f64.powi(ind) as f64);
    }
    println!("{:.18}", ans / n as f64);
}

Measured memory_bytes: 4352
import java.util.*;
public class Main {
		
	public static void main(String[] args) {		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.close();
		
		int count = 0;
		for(int i=1;i<=N;i++) {
			
			//111 -> 11 -> 1 -> 0
			int cnt = 0;
			
			int tmp = i;
			
			while(tmp != 0) {
				tmp/=10; // i = i / 10 ;  i = i + 3 -> i+=3; i = i+1 -> i++
				cnt ++;
			}
			
			if(cnt % 2 == 1) count ++;
			
		}
		System.out.println(count);
	}
	
}

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

using namespace std;

#define ff(i, a, b) for(int i = (a); (i <= (b)); ++i)
#define FF(i, a, b) for(int i = (a); (i >= (b)); --i)
#define ll long long
#define sz(a) (int)a.size()

struct re {
    int x, y;
    const bool operator < (const re &a) const {
        if (x != a.x) return x < a.x;
            return y < a.y;
    }
};

const int M = 1000000000 + 7;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    //freopen("", "r" , stdin);
    //freopen("", "w", stdout);
    ll n, a, b;
    cin >> n >> a >> b;
    if (a > b) swap(a, b);
    ll res = min((a + b - 1) / 2, (2 * n - a - b + 1) / 2);
    if (a % 2 == b % 2) res = min(res, (b - a) / 2);
    cout << res;
}
//This code belongs to s34vv1nd


Measured memory_bytes: 256
//Catchharsh
#include<bits/stdc++.h>
#define ll long long int 
#define ld long double
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define F first
#define S second
#define sz(x) x.size()
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define see(x) cout<<#x<<" = "<<x<<endl
const ll MOD = 1e9+7;
const ll INF = 1011111111;
const ll LLINF = 1000111000111000111LL;
const ld EPS = 1e-10;
const ld PI = 3.14159265358979323;
using namespace std;
ll power (ll base,ll exponent)
{
    ll ans=1;
    //base%=MOD;
    //exponent%=(MOD-1);
    while(exponent!=0)
    {
      if(exponent&1) ans=(1LL*ans*base);
      base=(1LL*base*base);
      exponent>>=1;
    }
    return ans;
}

int32_t main()
{   
     IOS;
     
    ll n,m,i,j,k;
    cin>>n;
    // vector<ll> v;
    // ll sz=0;
    ll sum=0;
    for(i=1;i<=n;i++)
    {
      if(i%3!=0&&i%5!=0) sum+=i;
    }
    cout<<sum;
    
     
     cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';             
}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
 
#define fi first
#define se second
#define pb push_back
 
#define limit (int) (1e7 + 5)
#define mod (int) 1000000007

using namespace std;
using lli = long long int;
using ulli = unsigned long long int;
using ld = long double;

lli a[limit];
bool isPrime[limit];
int main()
{
    // ios_base::sync_with_stdio(false);cin.tie(NULL);
    
    lli n;
    cin >> n;

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

    lli temp=0,c;
    for (int i = 2; i <= n; ++i)
    {
        if (isPrime[i])
        {
            for (int j = i; j <= n; j += i)
            {
                isPrime[j] = false;
                c = j;
                temp = 0;

                while(c%i == 0)
                {
                    temp++;
                    c /= i;
                }

                // if (j == 100)
                // {
                //     cout << i << " " << temp << "\n";
                // }

                a[j] *= temp+1;
            }
        }
    }

    // cout << a[100] << "\n";


    lli s = 0;

    for (lli i = 1; i <= n; ++i)
    {
        s += (a[i])*i;
    }

    cout << s;    
    return 0;
}





















Measured memory_bytes: 91432
#include<bits/stdc++.h>
using namespace std;
#define int long long
#undef int
#define mk make_pair
#define pb push_back
#define pf push_front
typedef pair<int, int> pii;
const int mod = 1000000007;
const int INF = 1000000009;
const long long INFL = 1000000000000000018ll;

int N;
string a[3];

signed main()
{
    cin >> N;
    cin >> a[0] >> a[1] >> a[2];
    int ans = 0;
    for(int i = 0; i < N; i++){
        int res = INF;
        for(int j = 0; j < 26; j++){
            char c = 'a' + j;
            int cnt = 0;
            if(a[0][i] != c){
                cnt++;
            }
            if(a[1][i] != c){
                cnt++;
            }
            if(a[2][i] != c){
                cnt++;
            }
            res = min(res, cnt);
        }
        ans += res;
    }
    cout << ans << endl;
}
/*


*/




Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int GCD(int x, int y) {
    if (y > x) swap(x,y);
    if (y == 0) return x;
    else return GCD(y, x % y);
}

int main(void){
    int n, X;
    cin >> n >> X;
    
    vector<int> x(n+1);
    for (int i = 0; i < n; i++) cin >> x[i];
    
    x[n] = X;
    
    if (n == 1){
        cout << abs(x[0] - x[1]) << endl;
        return 0;
    }
    
    // n >= 2
    sort(x.begin(),x.end());
    vector<int> diff(n);
    for (int i = 0; i+1 <= n; i++) diff[i] = x[i+1]-x[i];
    
    int ans =  GCD(diff[0],diff[1]);
    
    for (int i = 0; i < n; i++) ans = GCD(ans,diff[i]);
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using cd = complex <double>;

const long long INF = 1e18; 
const int mod = 200003;//1e9 + 7;//786433;//998244353;//1e9 + 7
const double Pi = acos(-1);
  
void Fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

int n;
int Root = 2;
int power[200005], cnt[200005];
long long a[200005];

vector <cd> Poly(524288);

void FFT(vector <cd> &A, bool invert)
{
	int n = A.size();
	if(n == 1)
	{
		return;
	}
	vector <cd> A0(n / 2), A1(n / 2);
	for(int i = 0; 2 * i < n; i++)
	{
		A0[i] = A[2 * i];
		A1[i] = A[2 * i + 1];
	}
	FFT(A0, invert);
	FFT(A1, invert);
	double ang = 2 * Pi / n * (invert ? -1 : 1);
	cd w(1), wn(cos(ang), sin(ang));
	for(int i = 0; 2 * i < n; i++)
	{
		A[i] = A0[i] + w * A1[i];
		A[i + (n / 2)] = A0[i] - w * A1[i];
		if(invert)
		{
			A[i] /= 2;
			A[i + (n / 2)] /= 2;
		}
		w = w * wn;
	}
}

signed main()
{
	Fastio();
	power[1] = 0;
	int temp = 1;
	for(int i = 1; i <= 200001; i++)
	{
		temp = temp * 2 % mod;
		power[temp] = i;
	}
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i];
		if(a[i] == 0)
		{
			continue;
		}
		cnt[power[a[i]]]++;
	}
	for(int i = 0; i < mod; i++)
	{
		Poly[i] = cd(cnt[i], 0);
	}	
	FFT(Poly, false);	
	for(int i = 0; i < 524288; i++)
	{
		Poly[i] = Poly[i] * Poly[i];
	}
	FFT(Poly, true);
	long long ans = 0;
	long long g = 1;
	for(int i = 0; i < 524288; i++)
	{
		ans += g * (long long)(Poly[i].real() + 0.5);
		g = g * 2 % mod;
	}
	for(int i = 1; i <= n; i++)
	{
		ans -= (a[i] * a[i] % mod);
	}
	cout << ans / 2;
}

Measured memory_bytes: 31448
n = int(input())
ans = [0] * n

for i in range(1, n):
    c, s, f = list(map(int, input().split()))

    for j in range(i):
        ans[j] = max(ans[j], s)
        ans[j] = ((ans[j]+f-1)//f) * f
        ans[j] += c

for a in ans:
    print(a)

Measured memory_bytes: 9216
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]

n,m=map(int,input().split())
a=list(map(int,input().split()))
sou=sum(a)/4/m
ans=0
for i in range(n):
    if a[i]>=sou:
        ans+=1

# print(ans)
if ans>=m:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 66156
#include<queue>
#include<cstdio>

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

using namespace std;

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

int main(){
	int h,w; scanf("%d%d",&w,&h);
	int B[102][102]={};
	rep(i,h) rep(j,w) scanf("%d",B[i+1]+j+1);
	h+=2; w+=2;

	bool vis[102][102]={};
	vis[0][0]=true;

	int ans=0;
	queue< pair<int,int> > Q; Q.push(make_pair(0,0));
	while(!Q.empty()){
		int y=Q.front().first,x=Q.front().second; Q.pop();
		rep(k,6){
			int yy=y+dy[k],xx=x+dx[y%2][k];
			if(0<=yy && yy<h && 0<=xx && xx<w && !vis[yy][xx]){
				if(B[yy][xx]==1) ans++;
				else{
					vis[yy][xx]=true;
					Q.push(make_pair(yy,xx));
				}
			}
		}
	}
	printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <typeinfo>

using namespace std;

int main(){
  int D;
  cin >> D;
  vector<string> ans={"Christmas Eve Eve Eve","Christmas Eve Eve","Christmas Eve","Christmas"};
  cout << ans.at(D-22) << endl;

  return 0;
}


Measured memory_bytes: 256
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def s(generator, splitter, mapper):
    return [ mapper(s) for s in generator().split(splitter) ]

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

n,d = get_nums_l()

points = [ list(map(int, s.split(" "))) for s in sys.stdin.readlines() ]

ans = 0
for ai, a in enumerate(points):
    for bi, b in enumerate(points):
        if ai <= bi :
            continue
        diss = 0
        for i in range(d):
            diss +=  (a[i]-b[i]) ** 2
        if math.sqrt(diss) % 1 < 0.00000000001:
            ans += 1

print(ans)

Measured memory_bytes: 38512
#include <bits/stdc++.h>
 
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>
 
using namespace std;

ll gcd(ll a, ll b){
	if(b==0) return a;
	return gcd(b,a%b);
}

ll mmc(ll a,ll b){

	return (a*b)/gcd(a,b);
}
 
ll func(ll a){
	ll cont=0;
	while(a%2==0){
		cont++;
		a/=2;
	}
	return cont;
}

int32_t main(){
	ll n,m,ma=0,l,aux,cont=0,r;
	cin >> n >> m;
	ll lcm = 1;

	cin >> aux;
	lcm=aux/2;
	r = func(aux);


	for(int i=1;i<n;i++){
		cin >> aux;
		lcm = mmc(lcm,aux/2);
		if(func(aux)!= r or lcm > m){
			cout << "0" << endl;
			return 0;
		}
	}

	l = 1;

	while(l*lcm<=m){
		cont++;
		l+=2;
	}


	cout << cont<< endl;

	return 0;
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

bool U[300000];

int main()
{
    ll M, K;
    cin >> M >> K;

    ll t = pow(2, M) - 1;
    ll xr = 0;
    REP(i, t + 1)
    {
        xr ^= i;
    }

    if (K == 0)
    {
        REP(i, pow(2, M + 1))
        {
            cout << i / 2 << " ";
        }
        cout << endl;
        return 0;
    }

    memset(U, 0, sizeof(U));
    if (xr xor K == K)
    {
        vector<ll> n;
        REP(i, 32)
        {
            if (((K >> i) & 1) == 1)
            {
                ll m = 1LL << i;
                if (m > t)
                {
                    cout << -1 << endl;
                    return 0;
                }
                n.push_back(m);
                U[m] = true;
            }
        }

        vector<ll> ans;
        REP(i, t + 1)
        {
            if (U[i])
                continue;
            ans.push_back(i);
        }
        REP(i, n.size())
        {
            ans.push_back(n[i]);
        }
        for (ll i = t; i >= 0; --i)
        {
            if (U[i])
                continue;
            ans.push_back(i);
        }
        for (int i = n.size() - 1; i >= 0; --i)
        {
            ans.push_back(n[i]);
        }

        REP(i, ans.size())
        {
            cout << ans[i] << " ";
        }
        cout << endl;
    }
    else
    {
        cout << -1 << endl;
    }
    return 0;
}

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

int main() {
  char A;
  char B;
  cin >> A;
  if(A=='a') B='b';
  else if(A=='b') B='c';
  else if(A=='c') B='d';
  else if(A=='d') B='e';
  else if(A=='e') B='f';
  else if(A=='f') B='g';
  else if(A=='g') B='h';
  else if(A=='h') B='i';
  else if(A=='i') B='j';
  else if(A=='j') B='k';
  else if(A=='k') B='l';
  else if(A=='l') B='m';
  else if(A=='m') B='n';
  else if(A=='n') B='o';
  else if(A=='o') B='p';
  else if(A=='p') B='q';
  else if(A=='q') B='r';
  else if(A=='r') B='s';
  else if(A=='s') B='t';
  else if(A=='t') B='u';
  else if(A=='u') B='v';
  else if(A=='v') B='w';
  else if(A=='w') B='x';
  else if(A=='x') B='y';
  else if(A=='y') B='z';
  cout << B << endl;
}

Measured memory_bytes: 256
# import sys
# input = sys.stdin.readline
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
# print(a)
# print(b)
# print(c)
count = sum(b)
for i in range(1,n):
    if (a[i]-1)==a[i-1]:
        count += c[a[i-1]-1]
print(count)

Measured memory_bytes: 3064
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel.Design;
using System.Globalization;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Schema;
using static System.Console;

namespace ConsoleApp2
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<int> Slist() {
            var t = ReadLine();
            if (t.Trim().Length == 0) return new List<int>();
            return new List<int>(t.Split().Select(int.Parse)); }
        static void Main(string[] args)
        {
            var H = Sarray()[0];
            WriteLine(f(H));
        }
        static long f(long x)
        {
            if (x == 1) return 1;
            return f(x / 2) * 2 + 1;
        }
    }
}


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

int main() {
  int N,K;
  cin >> N >> K ;
  vector<int> a(N);
  for(int i = 0 ; i < K ; i++){
  	int d_i;
    cin >> d_i;
    for(int j = 0; j < d_i ; j++){
      	int A_ij;
    	cin >> A_ij;
        for(int k = 0 ; k < N ; k++){
          if(A_ij == k+1){
          	a.at(k) = 1;
          }
        }
    }
  }

  int count = 0;
  for(int i = 0; i < N ; i++){
  	if(a.at(i) == 0){
    	count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3628
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int nx[26][100005];
int a[26];
int main(){
    string s, t;
    cin >> s >> t;
    int n = (int) s.size();
    s += s;
    for(int i = 0; i < 26; i++)a[i] = -1;
    for(int i = 2 * n - 1; i >= n; i--){
        a[s[i]-'a'] = i;
    }
    for(int i = n - 1; i >= 0; i--){
        for(int j = 0; j < 26; j++){
            nx[j][i] = a[j];
        }
        a[s[i]-'a'] = i;
    }
    int now = 0;
    int i = 0;
    if(t[0] == s[0])i++;
    ll ans = 0;
    for(; i < t.size(); i++){
        if(nx[t[i]-'a'][now] == -1){
            cout << - 1 << endl;
            return 0;
        }
        if(nx[t[i]-'a'][now] >= n)ans++;
        now = nx[t[i]-'a'][now] % n;
        show(now);
    }
    show(ans, now);
    cout << ans * n + now + 1 << endl;
}

Measured memory_bytes: 10880
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define DEBUG(debug_x) cerr <<#debug_x<<": "<<debug_x<<endl;
#define DEBUG2(debug_x, debug_y) cerr <<#debug_x<<":"<<debug_x<<" "<<#debug_y<<":"<<debug_y<<endl;
#define DEBUG3(debug_x, debug_y, debug_z) cerr <<#debug_x<<":"<<debug_x<<" "<<#debug_y<<":"<<debug_y<<" "<<#debug_z<<":"<<debug_z<<endl;
#define DEBUGVC(debug_x) cerr <<#debug_x<<": "; for(auto a:debug_x) cerr << a <<" "; cerr << endl;
#define DEBUGMP(debug_x) cerr <<#debug_x<<":"<<endl; for(auto a:debug_x) cerr << a.first <<" "<< a.second << endl;
#define MAX_N (200005)
#define INF (1LL << 60)
const int MOD = (int)1e9+7;
typedef pair<int,int> Pii;
typedef pair<double,double> Pdd;


int N, Q;
vector<int> G[MAX_N];
vector<bool> F(MAX_N,false);
vector<int> V(MAX_N,0);

void dfs(int s, int c){
    F[s]=true;
    V[s] = c;
    for(int i=0; i<G[s].size(); i++){
        int u = G[s][i];
        if(F[u]) continue;
        dfs(u,c+V[u]);
    }
}
 
signed main() {
    int N;
    cin >> N;
    vector<int> v(N);
    for(int i=0; i<N; i++) cin >> v[i];

    sort(v.begin(),v.end());

    double ans=(v[0]+v[1])/2.0;
    for(int i=2; i<N; i++){
        ans = (v[i]+ans)/2.0;
    }

    printf("%.10f\n", ans);

}


Measured memory_bytes: 6528
-- logic
compareThreeInts :: [Int] -> String
compareThreeInts i
  | i!!0 < i!!1 && i!!1 < i!!2 = "Yes"
  | otherwise = "No"

-- exec
main = do
  inNum <- getInts
  putStrLn $ compareThreeInts inNum

-- util
getInt :: (String -> Int)
getInt x = read x :: Int

getInts = do
  x <- getLine
  let y = (map$getInt)$words x
  return y


Measured memory_bytes: 3632
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//pair sort
bool compare_by_b(pair<LL, LL> a, pair<LL, LL> b) {
    if(a.second != b.second) return a.second < b.second;
    else return a.first < b.first;
}
std::uint32_t euclidean_gcd(std::uint32_t a, std::uint32_t b){return b != 0 ? euclidean_gcd(b, a % b) : a;}

const string YES = "Yes";
const string NO = "No";

void solve(long long H, long long N, std::vector<long long> A){
    LL sum=0;
    REP(i,N){
        sum += A[i];
    }
    if(sum >= H)cout<<YES<<endl;
    else cout<<NO<<endl;
}

int main(){
    long long H;
    scanf("%lld",&H);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(H, N, std::move(A));
    return 0;
}


Measured memory_bytes: 1024
import java.io.*;

public class Main {
    public static void main(String[] args) {
	try{
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
	while(true){
	    String line = reader.readLine();
	    int w = Integer.parseInt(line);
	    int s;
	    if(w==-1)break;
	    if(w<=10) {
		s = 1150;
	    }else if(w<=20) {
		s=1150+125*(w-10);
	    }else if(w<=30) {
		s=1150+1250+140*(w-20);
	    }else {
		s=1150+1250+1400+160*(w-30);
	    }
	    int x = 4280-s;
	    System.out.println(x);
	}
        }catch(IOException e){
	    System.out.println(e);
        }
    }
}

Measured memory_bytes: 16900
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		ArrayList<TreeSet<Integer>> list = new ArrayList<>();
		list.add(new TreeSet<>());
		int max = 0;
		for (int i = 0; i < n; i++) {
		    int x = sc.nextInt();
		    boolean added = false;
		    for (int j = list.size() - 1; j >= 0; j--) {
		        Integer y = list.get(j).ceiling(x);
		        if (y != null && y - k <= x) {
		            if (j == list.size() - 1) {
		                list.add(new TreeSet<>());
		            }
		            list.get(j + 1).add(x);
		            added = true;
		            break;
		        }
		        y = list.get(j).floor(x);
		        if (y != null && y + k >= x) {
		            if (j == list.size() - 1) {
		                list.add(new TreeSet<>());
		            }
		            list.get(j + 1).add(x);
		            added = true;
		            break;
		        }
		    }
		    if (!added) {
		        list.get(0).add(x);
		    }
		}
		System.out.println(list.size());
	}
}


Measured memory_bytes: 98832