akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
long long mod = 1000000007;
 
long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}
 
/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  
 
double eps = .000000001;

int main(){
  prep();
  long long n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  if (a > b){
      swap(a, b);
  }
  b -= a;
  a = 0;
  if (d*(n-1) < b){
      cout << "NO";
      return 0;
  }
  
  bool found = false;
  for (int i=0; i<=n-2 && !found; i++){
      long long cursum = -c*i+c*(n-1-i);
      if (cursum > b){
          long long maxdecr = c*(n-1-i)-d*i;
          if (b >= maxdecr){
              found = true;
          }
      }else if (cursum < b){
          long long maxincr= -c*i+d*(n-1-i);
          if (b <= maxincr){
              found = true;
          }
      }else{
          found = true;
      }
  }
  if (found){
      cout << "YES";
  }else{
      cout << "NO";
  }
  return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
  	int p,q,r;
  	cin >> p >> q >> r;
  	int a = (p>q)? p:q;
  	int b = (a>r)? a:r;
	cout << p+q+r-b << endl;
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 10;
const int MOD = 1000000007;

const string words[] = { "dream", "dreamer", "erase", "eraser" };

int main() {
	string str;
	cin >> str;
	int l = str.size();
	bool updated = true;

	while (l > 0 && updated) {
		updated = false;
		if (l >= 7) {
			if (str.substr(l - 7, 7) == "dreamer") {
				l -= 7;
				updated = true;
				continue;
			}
		}
		if(l >= 6) {
			if (str.substr(l - 6, 6) == "eraser") {
				l -= 6;
				updated = true;
				continue;
			}
		}
		if (l >= 5) {
			if (str.substr(l - 5, 5) == "dream") {
				l -= 5;
				updated = true;
				continue;
			}
			if (str.substr(l - 5, 5) == "erase") {
				l -= 5;
				updated = true;
				continue;
			}
		}
	}

	if (l == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}


	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <array>
#include <cmath>
#include <climits>
#include <cstdint>
using namespace std;

inline namespace atcoder {
    using i32 = int32_t; using u32 = uint32_t;
    using i64 = int64_t; using u64 = uint64_t;
    using f32 = float; using f64 = double;

    template <typename T, size_t Depth>
    struct vector_helper { using type = vector<typename vector_helper<T, Depth - 1>::type>; };
    template <typename T>
    struct vector_helper<T, 0> { using type = T; };
    template <typename T, size_t Depth>
    using vector_t = typename vector_helper<T, Depth>::type;

    template <typename T> using vec = vector_t<T, 1>;
    template <typename T> using vvec = vector_t<T, 2>;
    template <typename T> using vvvec = vector_t<T, 3>;
}

int main() {
    int n; cin >> n;
    vec<int> d(n);
    for (auto &e : d) cin >> e;
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            ans += d[i] * d[j];
        }
    }
    cout << ans << endl;
}



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

int check(vector<string>&list, string a){
    for(int i = 0; i < list.size(); i++){
        if(list[i] == a){
            return -1;
        }
    }
    return 1;
}

int main(){
    vector<string> list;
    string s; cin >> s;
    int k; cin >> k;
    for(int i = 0; i < s.size(); i++){
        string a;
        for(int l = 0; l < k; l++){
            if(l+i == s.size()){
                break;
            }
            a.push_back(s[i+l]);
            if(check(list, a) == 1){
                list.push_back(a);
            }
        }
    }
    sort(list.begin(), list.end());
    /*for(int i = 0; i < list.size(); i++){
        cout << list[i] << endl; 
    }
    cout << endl;*/
    cout << list[k-1] << endl;
}

Measured memory_bytes: 1024
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

// 行列ライブラリ
// Verified: TopCoder SRM 704 Div.2 (ModEquationEasy)
// 行列の積 と 累乗(繰り返し二乗法)

// Matrix Library Begin (C++11)

template <typename T>
using Matrix = vector< vector<T> >;

template <typename T>
void init_mat(Matrix<T> &A, int h, int w) {
    A.resize(h, vector<T>(w, 0));
}

template <typename T>
Matrix<T> calc_mat(Matrix<T> A, Matrix<T> B) {
    Matrix<T> C(A.size(), vector<T>(B[0].size()));
    for(int i=0; i<A.size(); i++) {
        for(int k=0; k<B.size(); k++) {
            for(int j=0; j<B[0].size(); j++) {
                // C[i][j] += A[i][k] * B[k][j]; // modなし
                C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % MOD; // modあり
            }
        }
    }
    return C;
}

template <typename T>
Matrix<T> mat_pow(Matrix<T> A, ll n) {
    Matrix<T> B(A.size(), vector<T>(A.size()));
    for(int i=0; i<A.size(); i++) B[i][i] = 1;
    while(n > 0) {
        if(n & 1) B = calc_mat(B, A);
        A = calc_mat(A, A);
        n >>= 1;
    }
    return B;
}

// Matrix Library End

signed main() {
    int N, K; cin >> N >> K;

    Matrix<int> mat;
    init_mat(mat, N, N);
    for(int i=0; i<N; i++) {
        for(int j=0; j<N; j++) {
            cin >> mat[i][j];
        }
    }

    mat = mat_pow(mat, K);

    int ans = 0;
    for(int i=0; i<N; i++) {
        for(int j=0; j<N; j++) {
            // cerr << mat[i][j] << " ";
            (ans += mat[i][j]) %= MOD;
        }
        // cerr << endl;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		boolean ok = true;
		int a = 0;
		int b = 0;
		int c = 0;
		int d = 0;
		while(sc.hasNext()) {
			int[] list = new int[3];
			for(int i = 0; i < 3; i++) {
				list[i] = sc.nextInt();
			}
			if(!ok) continue;
			Arrays.sort(list);
			if(list[0] + list[1] <= list[2]) ok = false;
			else {
				a++;
				if(list[0]*list[0] + list[1] * list[1] < list[2] * list[2])c++;
				else if(list[0]*list[0] + list[1] * list[1] > list[2] * list[2]) d++;
				else b++;
			}
		}
		System.out.println(a + " " + b + " " + d + " " + c);

	}



}

Measured memory_bytes: 23484
M = int(input())
A = [0] + list(map(int, input().split()))

B = [0] * (M + 1)

for i in range(M, 0, -1):
  j = 2
  tmp = 0
  while i * j <= M:
    B[i] += B[i * j]
    j += 1
  B[i] += A[i]
  B[i] %= 2
  
answer = []
for i in range(M + 1):
  if B[i]:
    answer.append(i)

if len(answer):
  print(len(answer))
  print(*answer)
else:
  print(0)

Measured memory_bytes: 70876
#include<cstdio>
#include<algorithm>
using namespace std;
long long C;
int A[200001];
int main() {
    int N,K;
	scanf("%d%d",&N,&K);
	for(int i=0;++i<=N;) scanf("%d",A+i);
	sort(A+1,A+N+1);
	for(int i=1;i<=N-K;++i)C+=A[i];
	printf("%lld\n",C);
    return 0;
}

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

#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

const ll mod = 998244353;
struct mint {
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

class combination{
private:
    vector<mint> fact,inv,finv;
public:
    combination(int N){
        fact = inv = finv = vector<mint>(N+1);
        fact[0] = fact[1] = 1;
        inv[0] = inv[1] = 1;
        finv[0] = finv[1] = 1;
        for(ll i=2;i<=N;i++){
            fact[i] = fact[i-1]*i;
//            inv[i] = (mint) mod - inv[mod%i]*(mod/i);
            finv[i] = fact[i].inv();
        }
    }
    mint f(int i){
        return fact[i];
    }
    mint comb(int n,int k){
        if(n<k) return 0;
        if(n<0 || k<0) return 0;
        return fact[n]*finv[k]*finv[n-k];
    }
    mint hcomb(int n,int k){
        if(n==0 && k==0) return 1;
        return comb(n+k-1,k);
    }
};


int main(){
    int N;
    cin >> N;
    mint ans = 1;
    combination c(N);
    vector<mint> beki2(N+1,1);
    for(int i=1;i<=N;i++) beki2[i] = beki2[i-1]*2;
    for(int i=0;i<N;i++) ans *= 3;
    for(int i=N/2+1;i<=N;i++) ans -= c.comb(N,i)*beki2[N-i]*2;
    cout << ans.x << endl;
}

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

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	string n;
	cin >> n;
	int sum=0;
	rep(i,(int)n.size()){
		sum+=n[i] - '0';
	}
	if(sum%9==0){
		cout << "Yes\n"; 
	}else{
		cout << "No\n";
	}
	return 0;
}

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

typedef long long ll;
const ll mod=1e9+7;
const ll N=2e5+1;
const ll INF=1e10;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	ll n,d;
	cin>>n>>d;
	int ans=0;
	for(int i=0;i<n;i++){
		ll x,y;
		cin>>x>>y;
		ans+=(d*d>=((x*x)+(y*y)));
	}
	cout<<ans;
}


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

struct tuple {
    int x;
    int y;
};

int asc(const void *a, const void *b) {
    return ((struct tuple *)a)->y - ((struct tuple *)b)->y;
}


int main(void){
    int N;
    int x,l;
    scanf("%d", &N);
    struct tuple A[1000000+10];
    for (int i = 0; i < N; i++) {
        scanf("%d %d", &x, &l);
        A[i].x = x - l;
        A[i].y = x + l;
    }
    qsort(A,N,sizeof (struct tuple), asc);
    int now = -1100000000;
    int cnt = 0;
    for (int i = 0; i < N; i++) {
        if (now <= A[i].x) {
            now = A[i].y;
            cnt++;
        }
    }
    printf("%d\n",cnt);
}


Measured memory_bytes: 3100
import sys
import socket

hostname = socket.gethostname()

if hostname == 'F551C':
    sys.stdin = open('a1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    n = read_int()
    if n == 1:
        res = 'Hello World'
    else:
        a = read_int()
        b = read_int()
        res = a + b
    print(res)


main()


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

string s;
map<string,bool> mem;

bool ok(string s){
	int n=s.length();
	if(n==0)return true;
	if(s[0]!='m'||s[n-1]!='w')return false;
	if(mem.find(s)!=mem.end())return mem[s];
	rep(i,n){
		if(s[i]=='e'){
			if(ok(s.substr(1,i-1))&&ok(s.substr(i+1,n-i-2)))return mem[s]=true;
		}
	}
	return mem[s]=false;
}

int main(){
	cin.sync_with_stdio(false);
	cin>>s;
	if(ok(s))cout<<"Cat"<<endl;
	else cout<<"Rabbit"<<endl;
	return 0;
}

Measured memory_bytes: 7380
def main():
    n = input()
    len_n = len(n)
    if n[1:] == "9" * (len_n - 1):
        print(int(n[0]) + 9 * (len_n - 1))
    else:
        print(int(n[0]) + 9 * (len_n - 1) - 1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 61880
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

int max_n = 101010;

ll MOD = 1e9 + 7;

int N, K;
vector<vector<int>> g(max_n, vector<int>());

ll dfs(int x, int p){

	int num;
	if(p == -1){
		num = K - 1;
	}else{
		num = K - 2;
	}

	if(K < g[x].size()){
		return 0;
	}

	ll ret = 1LL;
	for(int y : g[x]){
		if(y == p) continue;

		ret *= num;
		ret %= MOD;
		num--;
	}

	for(int y : g[x]){
		if(y == p) continue;
		ret *= dfs(y, x);
		ret %= MOD;
	}

	return ret;
}

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

	cin >> N >> K;

	rep(i, N-1){
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	ll ans = K * dfs(0, -1);
	ans %= MOD;
	cout << ans << endl;
}


Measured memory_bytes: 10496
n = int(input())
S = input()

west = [0]*(n+2)
east = [0]*(n+2)
ans = 10**6
for i in range(1,n+1):
	if S[i-1] == "W":
		west[i] = west[i-1]+1
	else:
		west[i] = west[i-1]
	if S[-i] == "E":
		east[-i-1] = east[-i]+1
	else:
		east[-i-1] = east[-i]

for i in range(1,n+1):
	ans = min(ans,west[i-1]+east[i+1])

print(ans)

Measured memory_bytes: 17616
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int[] ia = Stream.of(sc.nextLine().split("")).mapToInt(Integer::parseInt).toArray();
		int counter0 = 0;
		int counter1 = 0;

		for(int i : ia) {
			if(i==0)counter0++;
			if(i==1)counter1++;
		}

	    if (counter1 >= counter0) {
	        System.out.println(2 * counter0);
	     } else {
	        System.out.println(2 * counter1);
	     }

	}
}

Measured memory_bytes: 36800
import java.util.*;

public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int d = sc.nextInt();

    int ans = 0;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      cnt++;
      if (cnt == d + 1) {
        ans++;
        cnt = -d;
      }
    }

    if (cnt > 0) ans++;
    
    System.out.println(ans);
  }
}


Measured memory_bytes: 23252
a,b,h,m=map(int, input().split())
ang_a=(360/12)*h+30*m/60
ang_b=(360/60)*m
ang=abs(ang_a-ang_b)
if ang>180:
  ang=360-ang
else:
  ang=ang

import math
cosA=math.cos(math.radians(ang))
ans=(a**2+b**2-2*a*b*cosA)**0.5
print(ans)

Measured memory_bytes: 9512
s = list(str(input()))

n = len(s)
k = int((n+3)/2 - 1)
flag = 0
for i in range(n-1):
    if not s[i] == s[n-1-i]:
        break
else:
    flag += 1

for i in range(int((n-1)/2)):
    if not s[i] == s[int((n-1)/2 - 1 - i)]:
        break
else:
    flag += 1

for k in range (n):
    if not s[k] == s[n-1-k]:
        break
else:
    flag += 1

if flag == 3:
    print("Yes")
else:
    print("No")

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

vector<long> a,b,c;
long dp[100002][3];
int main(void){
    long N;
    cin >> N;
    a = b = c = vector<long>(N);

    for(long i=0;i<N;i++){
        cin >> a[i] >> b[i] >> c[i];
    }

    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];

    for(long i=1;i<N;i++){
        for(int j=0;j<3;j++){
            if(j == 0){
                dp[i][j] = max(dp[i-1][1]+a[i],dp[i-1][2]+a[i]); 
            }else if(j==1){
                dp[i][j] = max(dp[i-1][0]+b[i],dp[i-1][2]+b[i]);
            }else{
                dp[i][j] = max(dp[i-1][0]+c[i],dp[i-1][1]+c[i]);
            }
        }
    }

    long ans;
    ans = max(dp[N-1][0],max(dp[N-1][1],dp[N-1][2]));

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

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,count=0;
  cin >> N;
  string S;
  cin >> S;
  for(int i=2;i<N;i++){
    if(S[i-2]=='A' && S[i-1]=='B' && S[i]=='C'){
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]

num = 0
diff = 0
C = []
for a, b in zip(A, B):
  if a < b:
    num += 1
    diff -= (b - a)
  elif a > b:
    C.append(int(a - b))

if diff == 0:
  print(0)
else:
  C.sort(reverse=True)
  for v in C:
    num += 1
    diff += v
    if diff >= 0:
      break

  #print(diff)
  if diff < 0:
    print(-1)
  else:
    print(num)


Measured memory_bytes: 18356
#include <cstdio>
using namespace std;
typedef long long ll;
const int maxn = 100000;
int N,A[maxn]; ll x[maxn];
int main() {
    scanf("%d",&N); for (int i = 1;i <= N;i++) scanf("%d",&A[i]);
    x[1] = 0; for (int i = 1;i <= N;i++) if (i&1) x[1]+=A[i]; else x[1]-=A[i]; x[1]>>=1;
    for (int i = 2;i <= N;i++) x[i] = A[i-1]-x[i-1];
    for (int i = 1;i <= N;i++) printf("%lld ",x[i]<<1); printf("\n");
    return 0;
}


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

typedef long long ll;
typedef long double lld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
typedef pair<ll, ll> pll;
typedef pair<ll, pair<ll, ll>> plll;

void solve()
{
  ll n;
  cin >> n;
  string s = "";
  while (n > 0)
  {
    n--;
    int k = n % 26;
    s.push_back('a' + k);
    n /= 26;
  }
  reverse(s.begin(), s.end());
  cout << s << endl;
  return;
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  // int t;
  // cin >> t;
  // for (int i = 0; i < t; i++)
  // {
  //   solve();
  // }
  solve();
}

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

bool magic(int a, int b, int c, int k){
  
bool h = false;
int d = 0, e =0, f=0;
for(int i=0; i < k + 1; i++){
  for(int j =0; j < k-i+1; j++){
    for(int l = 0; l < k -i -j +1; l++){
    d = a* std::pow(2,i);
    e = b* std::pow(2,j);
    f = c* std::pow(2,l);

    if(d < e && e < f){
      h = true;
    }
    }
  }
}
 return h;
}

int main(){
 int a=0, b=0, c=0, k=0;
  
  cin >> a >> b >> c;
  cin >> k;
  if(magic(a, b, c, k)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
  
}


Measured memory_bytes: 4084
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>
#define INF 100000000
#define _INF -100000000
#define INFLL (long long)1e14
#define _INFLL (long long)-1e14
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<ll, ll> P;

int main() {
	int n, a, b; cin >> n >> a >> b;
	vi t(n);
	Loop(i, n) {
		cin >> t[i];
	}
	sort(t.begin(), t.end());
	int ans = n - (lower_bound(t.begin(), t.end(), b) - lower_bound(t.begin(), t.end(), a));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define p pair<int,int>
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

int N;
vector<p> dat;
int main(){
    cin >> N;
    for(int i = 1; i <= N; i++){
        int a;
        cin >> a;
        dat.push_back({a, i});
    }
    sort(dat.begin(), dat.end());
    for(int i = 0; i < N; i++){
        cout << dat[i].second << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1780
package main

import (
	"fmt"
	"sort"
)

func main() {
	var A, B int
	fmt.Scan(&A, &B)

	v := []int{
		A + B,
		A - B,
		A * B,
	}

	sort.Ints(v)
	fmt.Println(v[len(v)-1])
}


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

int main(){
	string find;
	string str;
	char buf[11];
	int a, cnt = 0;
	cin >> find;
	scanf("%d", &a);
	for (int i = 0; i < a; i++){
		str = "";
		scanf("%s", buf);
		str = str + buf + buf;
		if ((int)str.find(find) >= 0)cnt++;
	}
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 3292
N,K=map(int,input().split())
R,S,P=map(int,input().split())
T=str(input())
V=[]
W=[]
A=[]
x=0
for i in T:
  if i=="r":
    V.append("p")
  elif i=="s":
    V.append("r")
  else:
    V.append("s")
A=V[:]
for j in range(K):
  l=j
  while l<len(V):
    W.append(V[l])
    l=l+K
  #print(W)
  for i in range(1,len(W)):
    if W[i]==W[i-1]:
      if W[i]=="r":
        if i<len(W)-1 and W[i+1]=="s":
          W[i]="p"
        else:
          W[i]="s"
      elif W[i]=="s":
        if i<len(W)-1 and W[i+1]=="p":
          W[i]="r"
        else:
          W[i]="p"
      elif W[i]=="p":
        if i<len(W)-1 and W[i+1]=="r":
          W[i]="s"
        else:
          W[i]="r"
  #print(W)
  for i in range(len(W)):
    V[i*K+j]=W[i]
  W.clear()
"""print(V)
print(W)
print(A)"""
for i in range(len(V)):
  if V[i]==A[i]=="r":
    x=x+R
  elif V[i]==A[i]=="s":
    x=x+S
  elif V[i]==A[i]=="p":
    x=x+P
print(x)

Measured memory_bytes: 5784
s = input()
t = int(input())
a = []
now = 1
for i in range(1,len(s)):
    if (s[i]==s[i-1]):
        now += 1
    else:
        a.append(now)
        now = 1
a.append(now)
#print(a)
if (s[0]!=s[-1]):
    ans = 0
    for i in a:
        ans += i//2
    print(ans*t)
elif (len(a)==1):
    print(a[0]*t//2)
else:
    ans = 0
    for i in range(1,len(a)-1):
        ans += a[i]//2
    ans *= t
    ans += a[0]//2
    ans += a[-1]//2
    ans += (a[0]+a[-1])//2*(t-1)
    print(ans)
    

Measured memory_bytes: 3064
#from collections import deque,defaultdict
from sys import stdin
input = stdin.readline
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
a = inl()
x = 0
for i in range(n):
    x ^= a[i]
pad = ''
for i in range(n):
    printn(pad+str(x^a[i]))
    pad = ' '
print('')


Measured memory_bytes: 91984
#include<stdio.h>
int main (void){
    int a,b;
    char op;
    while (1)
    {
        scanf("%d %c %d",&a,&op,&b);
        if (op=='?')break;
        if (op=='+')printf("%d\n",a+b);
        if (op=='-')printf("%d\n",a-b);
        if (op=='*')printf("%d\n",a*b);
        if (op=='/')printf("%d\n",a/b);
        if (op=='%')printf("%d\n",a%b);
    } 
    return 0;
}


Measured memory_bytes: 2064
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val K, A, B = in.nextInt

  def judge(k: Int): Boolean = {
    if (A <= k && k <= B) true
    else if (k > B) false
    else judge(k + K)
  }
  println(if(judge(K)) "OK" else "NG")
}

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

using namespace std;

typedef long long ll;

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

#define per(i, n) for (int i = n ; i >= 0 ; --i)

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

  ll n, m;
  cin >> n >> m;

  ll result = 0;
  ll tmp = floor(m / 2);
  if (tmp >= n) {
    result += n;
    m -= n * 2;
  } else {
    result += tmp;
    m -= tmp * 2;
  }

  result += floor(m / 4);

  cout << result << '\n';

  return 0;
}

Measured memory_bytes: 3660
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <string>
#include <map>
#include <iostream>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <climits>
#include <limits>
#include <queue>
#include <utility>

using namespace std;



#define ll long long

	int main() {

		unordered_map<int, int> freq;
		int n;
		cin >> n;
		ll sum = 0;
		for (int i = 0; i < n; i++) {
			int val;
			cin >> val;
			sum += val;
			if (freq.find(val) == freq.end())
				freq[val] = 0;
			freq[val]++;
		}
	
		int q;
		cin >> q;

		for (int i = 0; i < q; i++) {
			int b, c;
			cin >> b >> c;
			if (freq.find(b) == freq.end()) {
				cout << sum << endl;
				continue;
			}
			int freqB = freq[b];
			sum -= ((ll)freqB * (ll)b);
			sum += ((ll)freqB * (ll)c);
			if (freq.find(c) == freq.end())
				freq[c] = 0;
			freq[c] += freqB;
			freq.erase(b);
			cout << sum << endl;
		}

		return 0;
	}




Measured memory_bytes: 6692
#define _CRT_SECURE_NO_WRANINGS
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <iterator>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
 
#define FOR(i,n) for(int i = 0; i < (n); i++)
#define sz(c) ((int)c.size())

typedef unsigned long long ull;
const int INF = (int)1e8;

char t[256];

enum DRCT {L,R,U,D,NONE};
 
int R_table[6][4] = {
    {2,3,5,4},
    {3,1,4,6},
    {2,6,5,1},
    {1,5,6,2},
    {1,3,6,4},
    {4,5,3,2}
};
 
struct DIE{
    int t,f;

	DIE() : t(1),f(2) {}
 
    int getR(){
        int id = find(R_table[t-1],R_table[t-1] + 4,f) - R_table[t-1];
        id = (id + 1) % 4;
        return R_table[t-1][id];
    }
	int getL(){
        int id = find(R_table[t-1],R_table[t-1] + 4,f) - R_table[t-1];
        id = (id + 3) % 4;
        return R_table[t-1][id];
    }
 
    DRCT getDir(int x){
        if(x == t) return NONE;
        else if(t + x == 7) return NONE;
        else if(f == x) return U;
        else if(f + x == 7) return D;
        int r = getR();
        if(x == r) return R;
        else return L;
    }
 
    void rot(DRCT dr){
        if(dr == L){
            t = getR();
        } else if(dr == R){
            t = 7 - getR();
        } else if(dr == U){
            int nt = 7 - f;
            f = t;
            t = nt;
        } else {
            int nf = 7 - t;
            t = f;
            f = nf;
        }
    }
};

int main(){
	int n;
	while(cin>>n,n){
		DIE die;
		int ans = 1;
		FOR(i,n){
			string s; cin>>s;
			switch(s[0]){
			case 'N':
				die.rot(D);
				break;
			case 'E':
				die.rot(R);
				break;
			case 'W':
				die.rot(L);
				break;
			case 'S':
				die.rot(U);
				break;
			case 'R':
				die.f = die.getR();
				break;
			case 'L':
				die.f = die.getL();
				break;
			}
			ans += die.t;
		}
		cout << ans << endl;
	}
    return 0;
}

Measured memory_bytes: 1208
Input = input().split()
a = int(Input[0])
b = int(Input[1])
c = int(Input[2])
yakusuu = 0
if a >= 1 and b >= 1 and c >= 1:
    if a <= 10000 and b <= 10000 and c <= 10000:
        if a <= b:
            while a <= b:
                if c % a == 0:
                    yakusuu += 1
                a += 1
print(yakusuu)

Measured memory_bytes: 7660
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<ll,ll> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
int gcd(int a,int b){if(a<b)swap(a,b);int c=a%b;while(c!=0){a=b;b=c;c=a%b;}return b;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};


int main(){
  int a, b, c, k; cin >> a >> b >> c >> k;
  ll sum = 0;
  if (k <= a){
    sum = k;
  }else{
    sum += a;
    if (k > a + b){
      sum += -1 * (k - (a + b));
    }
  }
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>

int k, t;
int a[100];
int sum, max;
int na;
int dap;

int main()
{
    scanf("%d%d", &k, &t);
    for(int i=0; i<t; i++) {
        scanf("%d", a+i);
        sum+=a[i];
        if(max<a[i]) max=a[i];
    }

    na=sum-max;
    if(max<na+1) dap=0;
    else dap=max-na-1;
    printf("%d", dap);

    return 0;
}

Measured memory_bytes: 128
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

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

uf = UnionFind(N)  
for i in range(M):
  a, b = map(int, input().split())
  uf.union(a-1, b-1)
  
count = uf.group_count()  
print(count - 1)




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

int main(){
  int64_t n,sum=0;
  cin >> n;
  n++;
  for(int i=1;i<n;i++){
    if((i%3!=0) && (i%5!=0)) sum+=i;
  }
  cout << sum << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define repl(i, l, r) for (int i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int g[15][15];

int main()
{
    int n;
    cin >> n;
    rep(i, n) rep(j, n) g[i][j] = -1;
    rep(i, n) {
        int m;
        cin >> m;
        rep(j, m) {
            int a, x;
            cin >> a >> x;
            a--;
            g[i][a] = x;
        }
    }
    int ans = 0;
    rep(i, 1 << n) {
        vector<int> d(n);
        rep(j, n) {
            if(i >> j & 1) {
                d[j] = 1;
            }
        }
        bool ok = true;
        rep(j, n) {
            if(d[j]) {
                rep(k, n) {
                    if(g[j][k] == -1) continue;
                    if(g[j][k] != d[k]) ok = false;
                }
            }
        }
        if(ok) ans = max(ans, __builtin_popcount(i));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main(void){
    // Your code here!
    static const double pi = 3.141592653589793;
    int A,B,H,M;
    cin >> A >> B >> H >> M;
    double h = pi*0.5*(60*H+M)/180;
    double m = pi*6*M/180;
    double res = sqrt(A*A+B*B-2*A*B*cos(h-m));
    cout << fixed << setprecision(15) << res << endl;
}


Measured memory_bytes: 4192
package main

import (
	"fmt"
)

func main() {
	var c string
	fmt.Scan(&c)

	alps := []string{
		"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z",
	}

	for i, a := range alps{
		if c == a {
			fmt.Print(alps[i+1])
			return
		}
	}
	return
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}

const string YES = "YES";
const string NO = "NO";

void solve(std::string S){
  int cnt=0;
  for (auto &&i : S)
  {
    if(i=='o')cnt++;
  }
  if(cnt+15-S.size()>=8){
    cout<<YES<<endl;
  }else{
    cout<<NO<<endl;
  }
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
#ifndef DEBUG
#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (Int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP(i, n) for (Int i = 0, i##_len = (n); i <= i##_len; ++i)
#define rep3(i, l, r) for (Int i = l, i##_len = (r); i < i##_len; ++i)
#define REP3(i, l, r) for (Int i = l, i##_len = (r); i <= i##_len; ++i)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;
const Int INF = 1LL << 62;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

Int Ceil(Int a, Int b) {
    if (a % b == 0) {
        return a / b;
    } else {
        return Floor(a, b) + 1;
    }
}

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

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

Int digits(Int n) {
    return (Int)to_string(n).size();
}

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

    Int n;
    cin >> n;
    vector<Int> a(n);
    for (Int i = 0; i < n; i++) {
        cin >> a[i];
    }

    Int ans = 0, m = a.front();
    for (Int i = 0; i < n; i++) {
        if (a[i] < m) {
            ans += m - a[i];
        } else {
            m = a[i];
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4760
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		long X = sc.nextLong();
		long l = 1;
		while (l * (l + 1) / 2 < X)
			++l;
		System.out.println(l);
	}
}

Measured memory_bytes: 23124
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
#define ll long long
#define ld long double
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	if(a>b) swap(a, b);
	for(int i=0; i<b; ++i) cout << a;
	cout << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sc(n) scanf("%d",&n)
#define scl(n) scanf("%lld",&n)
#define pr(n) printf("%d",n)
#define prl(n) printf("%lld",n)
#define nl printf("\n")
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
ll pow1(ll a, ll b)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
		{
			ans=ans*a;
		}
		a=a*a;
		b=b>>1;
	}
	return ans;
}
int main()
{
	ll x,k,n;
	cin>>x>>k;
	if(500*x >= k)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

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

// BE CAREFUL WITH HASH TABLE & UNORDERED MAP
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
using namespace std;

#define MOD 998244353
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = (b-1); i >= (a); i--)
#define RF0(i,b) RFO(i,0,b)
#define lli long long int
#define pii pair<int,int>
#define add(a,b) ((int) (((lli) (a) + (b))%MOD))
#define mul(a,b) ((int) (((lli) (a) * (b))%MOD))
#define PB emplace_back
#define F first
#define S second

// ifstream cin ("cinput.in");
// ofstream cout ("coutput.out");

lli N;
vector<lli> nfact;
vector<lli> nfact1;

void fact(lli n, vector<lli>& store) {
    for (lli i = 1; i*i <= n; i++) {
        if (n%i == 0) {
            store.PB(i);
            if (i*i != n) store.PB(n/i);
        }
    }
}

// Helper Functions

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N;
    fact(N, nfact);
    fact(N-1, nfact1);

    int ans = nfact1.size() - 1;
    // cout << "pre: " << ans << '\n';
    for (lli cand: nfact) {
        if (cand == 1) continue;
        lli h = N;
        while (!(h%cand)) h /= cand;
        if (h%cand == 1) ans++;
    }
    cout << ans << '\n';
}

Measured memory_bytes: 3236
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
using namespace std;
using vector3D = vector< vector<string> >;
const int B = 5;

int N;
int X[30], Y[30];

vector3D get_next_day(const vector3D& board) {
  vector3D ret(B, vector<string>(B, string(B, '0')));

  for(int z=0; z<B; z++) {
    for(int x=0; x<B; x++) {
      for(int y=0; y<B; y++) {

        int is_exist_creature = board[z][x][y] - '0';
        int cnt_neighbor = 0;
        for(int dz=-1; dz<=1; dz++) {
          for(int dx=-1; dx<=1; dx++) {
            for(int dy=-1; dy<=1; dy++) {
              int nx = x + dx, ny = y + dy, nz = z + dz;

              // identical
              if(nx == x && ny == y && nz == z) continue;
              // out of range
              if(nx < 0 || nx >= B || ny < 0 || ny >= B || nz < 0 || nz >= B) continue;
              
              cnt_neighbor += board[nz][nx][ny] - '0';
            }
          }
        }

        if(!is_exist_creature) {
          // printf("z = %d, x = %d, y = %d, cnt_neighbor = %d\n", z, x, y, cnt_neighbor);
          ret[z][x][y] = (char)(X[cnt_neighbor] + '0');
        }
        else {
          ret[z][x][y] = (char)(Y[cnt_neighbor] + '0');
        }
      }
    }
  }
  return ret;
}

int main() {
  int case_num = 0;
  while(cin >> N, N) {
    if(case_num) cout << endl;
    case_num++;
    vector3D board(B, vector<string>(B, string(B, '0')));
    
    for(int z=0; z<B; z++) {
      for(int x=0; x<B; x++) {
        cin >> board[z][x];
      }
    }
    memset(X, 0, sizeof(X));
    memset(Y, 0, sizeof(Y));

    int numA, numB;
    cin >> numA;
    for(int i=0; i<numA; i++) {
      int val; cin >> val;
      X[val] = 1;
    }
    cin >> numB;
    for(int i=0; i<numB; i++) {
      int val; cin >> val;
      Y[val] = 1;
    }
    
    for(int i=0; i<N; i++) {
      board = get_next_day(board);
    }

    printf("Case %d:\n", case_num);
    for(int z=0; z<B; z++) {
      for(int x=0; x<B; x++) {
        cout << board[z][x] << endl;
      }
      if(z+1 != B) cout << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep1n(i,n) for(int i=1; i<=(n); ++i)
#define repxn(i,x,n) for(int i=x; i<=(n); ++i)
#define sort_u(x) sort((x).begin(),(x).end())
#define sort_d(x) sort((x).begin(),(x).end(), greater<int>())
#define pb push_back
#define INF 1001001001  // 浮動小数点型
#define INF_L 1001001001001001001  // 浮動小数点型
#define bit(n,m)(((n)>>(m))&1)  // nのmビット目が1
#define MOD 1000000007
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
#define yn2 {puts("YES");}else{puts("NO");}
template<typename T>bool mins(T& x,const T&y){if(x>y){x=y;return true;}else return false;}

ll choose(ll a){
    return (a*(a-1))/2;
}

int main() {
    int n; cin>>n;
    vector<int> a(n); rep(i, n) cin >> a[i];
    rep(i,n) a[i]--;
    vector<int> cnt(n);
    rep(i,n) cnt[a[i]]++;
    ll ans=0;
    rep(i,n){
        //if(cnt[i]<2) continue;
        ans += choose(cnt[i]);
    }
    rep(i,n){
        ll tot = ans;
        tot -= choose(cnt[a[i]]);
        tot += choose(cnt[a[i]]-1);
        cout << tot << endl;
        // cout << ans - choose(cnt[a[i]]) + choose(cnt[a[i]]-1) << endl;        
    }
    
}

/*
g++ c.cpp
./a.out
./problem.exe
oj d
oj t

debug:ctrl+shift+B problemin

*/


Measured memory_bytes: 4848
N = int(input())
A = list(map(int, input().split()))

all = abs(A[0]) + abs(A[N-1])
for i in range(N-1):
    all += abs(A[i+1] - A[i])

print(all - (abs(A[0]) + abs(A[1]-A[0])) + abs(A[1]))

for i in range(1, N-1):
    print(all- (abs(A[i+1]-A[i]) + abs(A[i-1] - A[i])) + abs(A[i+1]-A[i-1]))
    
print(all - (abs(A[N-1])+abs(A[N-1]-A[N-2])) + abs(A[N-2]))


Measured memory_bytes: 14168
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<queue>
#include<stack>
#include<utility>
#include<vector>
using namespace std;

typedef long long lint;

int main(){
    // 各数値の入力
    lint n, m;
    cin >> n >> m;
    vector<lint> x(n), y(n), z(n);
    for(lint i = 0 ; i < n ; i++){
        cin >> x[i] >> y[i] >> z[i];
    }

    lint ans = 0; // 答えを格納する変数
    for(lint i = 0 ; i < 8 ; i++){ // x, y, zについて、それぞれ+と-の場合を考えるので8通りに場合分け
        // 0~7を1と-1で擬似的に2進数で表記する
        vector<lint> vec(4, 1);
        lint tmp = i, j = 0;
        while(tmp > 0){
            if(tmp % 2 != 0){
                vec[j] = -1;
            }
            tmp /= 2;
            j++;
        }
        vector<lint> solve(n);
        for(lint k = 0 ; k < n ; k++){
            // 先程の2進数で表記したものを、1の位をx,2の位をy,3の位をzにかけることで、符号による場合分けができる
            solve[k] = vec[0] * x[k] + vec[1] * y[k] + vec[2] * z[k];
        }
        // 降順に並べ替えて、先頭からM個足す
        sort(solve.rbegin(), solve.rend());
        lint t = 0;
        for(lint k = 0 ; k < m ; k++){
            t += solve[k];
        }
        // 求めたものと、1つ前までの最大値を比較して、最大値を答えとする
        ans = max(ans, t);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;

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

const ll MOD = 9223372036854775807; // 1e9+7;

vvl initialize(int r, int c) {
  /*
   * r行c列の2次元零行列
   */
  vvl I = vvl(r);
  REP (i, r) {
    I[i] = vl(c, 0);
  }
  return I;
}

vvl mul(vvl A, vvl B) { // A*B
  vvl C = initialize(A.size(), B[0].size());
  REP (i, A.size()) REP (k, B.size()) REP (j, B[0].size()) {
    C[i][j] = (C[i][j] + 1l * A[i][k] * B[k][j]) %MOD;
  }
  return C;
}

vvl pow(vvl A, ll n) { 
  /*
   * Aのn乗の行列
   * Aは正方行列
   */
  int d = A.size();
  vvl B = initialize(d, d);
  REP (i, d) B[i][i] = 1; // Aと同じ次元の単位行列を作成
  while (n > 0) {
    if (n&1) B = mul(A, B);
    A = mul(A, A);
    n >>= 1;
  }
  return B;
}

ll fibonacci(ll n) {
  vvl A = initialize(2,2);
  A[0][0] = A[0][1] = A[1][0] = 1;
  A[1][1] = 0;
  A = pow(A, n+1);
  return A[1][0];
}

ll n;

int main() {

  cin >> n;
  cout << fibonacci(n) << endl;;
  return 0;
}



Measured memory_bytes: 3180
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007

using namespace std ;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;




int main()
{
  int a, b, c, d, e ;
  cin >>  a >> b >> c >> d >> e ;
  int A, B, C, D, E ;
  A = (10-a%10)%10 ;
  B = (10-b%10)%10 ;
  C = (10-c%10)%10 ;
  D = (10-d%10)%10 ;
  E = (10-e%10)%10 ;
  int sum ;
  
  int ma = max({A,B,C,D,E}) ;
  if(A==0){
    a = a-10 ;
  }
  if(B==0){
    b = b-10 ;
  }
  if(C==0){
    c = c-10 ;
  }
  if(D==0){
    d = d-10 ;
  }
  if(E==0){
    e = e-10 ;
  }
  sum = (a/10+1)*10+(b/10+1)*10+(c/10+1)*10+(d/10+1)*10+(e/10+1)*10-ma ;
  
  cout << sum << endl ;
  
 
  return 0 ;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)
#define int long long
#define debug(var) cout << "[" << #var << "] " << var << endl
//using ll = long long;
using ipair = pair<int,int>;
 
bool operator> (const pair<int,int> a, const pair<int,int> b){return a.second > b.second;};
bool operator< (const pair<int,int> a, const pair<int,int> b){return a.second < b.second;};
 
const int INF = 1<<29;
const double EPS=1e-9;
const int MOD=998244353;

int GetDigit(int num){
    int digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit-1;
}

signed main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep (i, N) cin >> A[i];
 
    int ans = 1;
    bool flag = false;
    rep (i, N) {
        if (ans > (int)pow(10, 18)) {
            flag = true;
        }
        if (A[i] == 0) {
            flag = false;
            ans = 0;
            break;
        }
        // cout << ans * A[i] << endl;
        if (GetDigit(ans) + GetDigit(A[i]) >= 18 && ans * A[i] != (int)pow(10, 18)){
            flag = true;
        }
        ans *= A[i];
    }
    if (ans > (int)pow(10, 18) || flag) {
        cout << -1;
    } else {
        cout << ans;
    }
}

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

int main() {
  string x;
  cin >> x;
  
  int count=0;
  if (x.at(0) == '1')
    count++;
  if (x.at(1) == '1')
    count++;
  if (x.at(2) == '1')
    count++;
  cout << count << endl;
}

Measured memory_bytes: 256