akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
	int [][] field;
	int goalx;
	int goaly;
	int moveColor;

	private boolean move(int x, int y){

		if(field[y][x] != moveColor){
			return false;
		}
		if(x == goalx && y == goaly){
			return true;
		}

		field[y][x] = -1;
		if(move(x+1,y) || move(x,y+1) || move(x-1,y) || move(x,y-1))
			return true;
		else
			return false;

	}

	public void doIt(){
		Scanner sc = new Scanner(System.in);
		field = new int[102][102];
		while(true){
			int w = sc.nextInt();
			int h = sc.nextInt();
			if(w == 0 && h == 0)
				break;
			for(int i=0; i < 102; i++){
				for(int j=0;j < 102; j++){
					field[i][j] = 0;
				}
			}
			int xs = sc.nextInt();
			int ys = sc.nextInt();
			goalx = sc.nextInt();
			goaly = sc.nextInt();
			int n = sc.nextInt();

			//read a block
			int [][] block = new int[n][4];
			for(int i=0; i < n; i++){
				for(int j=0; j < 4; j++){
					block[i][j] = sc.nextInt();
				}
				int x = block[i][2];
				int y = block[i][3];
				if(block[i][1] == 0){
					for(int k=y; k < y+2; k++ ){
						for(int j=x; j < x+4; j++){
							field[k][j] = block[i][0];
						}
					}
				}
				else{
					for(int k=y; k < y+4; k++ ){
						for(int j=x; j < x+2; j++){
							field[k][j] = block[i][0];
						}
					}
				}
			}

			//set flame
			for(int i=0; i <= w + 1; i++){
				field[0][i] = -1;
				field[h+1][i] = -1;
				field[i][0] = -1;
				field[i][w+1] = -1;
			}

			//start
			boolean ans;
			moveColor = field[ys][xs];
			if(moveColor == 0){
				ans= false;
			}
			else{
				ans = move(xs, ys);
			}

			//print
			if(ans)
				System.out.println("OK");
			else
				System.out.println("NG");

		}

	}
	public static void main(String[] args) {
		Main obj = new Main();
		obj.doIt();

	}

}

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

int main() {
    int64_t X;
    int64_t P = 100;
    int64_t year = 0;
    cin >> X;

    while(P < X){
        P = 1.01*P;
        year++;
    }

    cout << year << endl;
}


Measured memory_bytes: 3624
N = int(input())

X = [[] for _ in range(10**5)]
Y = [[] for _ in range(10**5)]

P = [tuple(map(lambda x: int(x) - 1, input().split())) for _ in range(N)]

for i in range(N):
    x, y = P[i]
    X[x].append(y)
    Y[y].append(x)

x_used = [0 for _ in range(10**5)]
y_used = [0 for _ in range(10**5)]
res = 0

for i in range(10**5):
    if x_used[i]:
        continue
    stack = [(0, i)]
    x_cnt = 1
    x_used[i] = 1
    y_cnt = 0
    edge = 0
    while stack:
        axis, node = stack.pop()
        if axis == 0:
            for adj in X[node]:
                edge += 1
                if y_used[adj]:
                    continue
                y_cnt += 1
                y_used[adj] = 1
                stack.append((1, adj))
        else:
            for adj in Y[node]:
                if x_used[adj]:
                    continue
                x_cnt += 1
                x_used[adj] = 1
                stack.append((0, adj))
    res += x_cnt * y_cnt - edge

print(res)

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

int main(){
	int n;
  	cin >> n;
  	while(n > 0){
		if(n % 10 == 9){
          cout << "Yes" << endl;
          return 0;
        }
      	n /= 10;
    }
  	cout << "No" << endl;
  	return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>

using namespace std;

int n, ct = 0;
bool p[1000001];

int main(){
	for (int i = 0; i < 1000001; i++) p[i] = 1;
	for (int i = 2; i < 1000; i++){
		if (p[i] == 1){
			for (int j = 0; i*(j + 2) < 1000000; j++){
				p[i*(j + 2)] = 0;
			}
		}
	}
	while (cin >> n){
		for (int i = 2; i < n + 1; i++)
			if (p[i] == 1) ct++;
		cout << ct << endl;
		ct = 0;
	}
}

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

int main(){
    long long x, y;
    cin >> x >> y;
    if (x * y == 0){
        if (x == 0){
            if (y > 0) cout << y << endl;
            else cout << abs(y) + 1 << endl;
        }
        else {
            if (x > 0) cout << x + 1 << endl;
            else cout << abs(x) << endl;
        }
    }
    else if (x * y > 0){
        if (y > x) cout << abs(y - x) << endl;
        else cout << abs(y - x) + 2 << endl;
    }
    else cout << abs(abs(y) - abs(x)) + 1 << endl;
}


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

using namespace std;

#define ll long long
#define ld long double
#define ff first
#define ss second
#define rsz resize
#define ins insert 
#define mp make_pair
#define pf push_front 
#define pb push_back
#define eb emplace_back 
#define ft front() 
#define bk back()
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define deb(x) cout<<#x<<" "<<x<<'\n';
#define rep(i,a,b) for (int i = (a); i < (b); ++i)

const ll mod = 1e9+7; // 998244353;
const ll inf = 1e18; 
const ld pie = acos((ld)-1);

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



int main(){
    
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll m1 = a*c;
	ll m2 = a*d;
	ll m3 = b*d;
	ll m4 = b*c;
	printf("%lld",max(m1,max(m2,max(m3,m4))));

	return 0;
	/*STUFF TO LOOK:	
		1. Check the constraints
		2. Corner cases(n==0||n==1)
		3. Variables in loops
		4. Make sure two ints aren’t multiplied to get a long long
		5. Don't use scanf or printf while using ios_base
		6. using the local variable of the same name when global variable was required to be used
	*/
}


Measured memory_bytes: 3752
// clang-format off
	#include <bits/stdc++.h>
	using namespace std; using ll = long long; using uint = unsigned int;
	#define SFINAE(x, ...)	template <class, class = void> struct x : false_type {}; template <class T> struct x<T, void_t<__VA_ARGS__>> : true_type {};
	SFINAE(DefaultIO, decltype(cout << declval<T &>()))
	SFINAE(IsTuple, typename tuple_size<T>::type)
	SFINAE(Iterable, decltype(begin(declval<T>())))
	template <class T> constexpr char Space(const T &) { return (Iterable<T>::value or IsTuple<T>::value) ? '\n' : ' '; }
	template <auto &os> struct Writer {
		template <class T> void Impl(T const &t) const {
			if constexpr (DefaultIO<T>::value) os << t;
			else if constexpr (Iterable<T>::value) { int i = 0; for (auto &&x : t) ((i++) ? (os << Space(x), Impl(x)) : Impl(x)); }
			else if constexpr (IsTuple<T>::value) apply([this](auto const &... args) { int i = 0; (((i++) ? (os << ' ', Impl(args)) : Impl(args)), ...);}, t);
			else static_assert(IsTuple<T>::value, "No matching type for print");
		}
		template <class F, class... Ts> auto &operator()(F const &f, Ts const &... ts) const { return Impl(f), ((os << ' ', Impl(ts)), ...), os << '\n', *this; }
	};
	template <auto &is> struct Reader {
		template <class T> auto& operator()(T &t) const {
			if constexpr (DefaultIO<T>::value) is >> t;
			else if constexpr (Iterable<T>::value) for (auto &x : t) (*this)(x);
			else if constexpr (IsTuple<T>::value) apply([this](auto &... args) { ((*this)(args), ...); }, t);
			else static_assert(IsTuple<T>::value, "No matching type for read");
			return *this;
		}
	};
	#ifdef NARUT_LOCAL
	#define Debug(...) cerr << "\033[0;31m", Writer<cerr>{}(__VA_ARGS__), cerr << "\033[0m\n"
	#else
	#define Debug(...) 0
	#endif
	[[maybe_unused]] constexpr Reader<cin> Cin; [[maybe_unused]] constexpr Writer<cout> Cout;
	#define FOR(i, j, n) for (int i = int(j); i < int(n); ++i)
	#define ROF(i, j, n) for (int i = int(n) - 1; i >= int(j); --i)
// clang-format on





auto Main() {
	int n;
	cin>>n;

	vector<int> A(n+1, 1);
	for(int p = 2; p <= n; ++p) {
		for(int i = p; i <= n; i += p) A[i]++;
	}

	ll ans = 0;
	FOR(i,0,n+1) ans += i*1ll*A[i];

	cout<<ans;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(10);
#ifdef NARUT_LOCAL
	assert(freopen("io/test.in", "r", stdin));
	cin.exceptions(cin.badbit | cin.failbit);
	cerr << fixed << setprecision(10);
#endif

	Main();
}


Measured memory_bytes: 42264
#include <iostream>
#include <vector>
using namespace std;
int n, m, v[1000];
int main(){
    cin >> n >> m;
    int nr = 0, sum = 0;
    for(int i = 1; i <= n; ++i){
        cin >> v[i]; 
        sum += v[i];
    }
    for(int i = 1; i <= n; ++i)
        if(v[i] * 4 * m >= sum) nr++;
    cout << (nr >= m ? "Yes" : "No");
}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

ll N;

ll digit(ll x) {
    ll ret = 0;
    while (x > 0) { 
       ret++;
       x /= 10; 
   }
   return ret; 
}

ll f(ll x) {
   if (N % x == 0) {
      return max(digit(x), digit(N/x));
   } else {
      return -1;
   }
}

int main() {
   cin >> N;
   // debug(digit(N))

   ll ans = digit(N);
   for (ll i = 1; i*i <= N; i++) {
      // debug(ans)
      ll t = f(i);
      if (t == -1) continue;
      // debug3(i, N/i, t)
      ans = min(ans, t);
   }
   cout << ans << endl;

   return 0;
}

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



int main(){
	char a[4],b[3];
	int i, j,ans=0;
	scanf("%s",a );
	for (i = 0; i < 1 << 3; i++) {
		ans = a[0]-'0';
		for (j = 0; j < 3; j++) {
			if ((1 & (i >> j)) == 1) {
				ans += a[j + 1]-'0';
				b[j] = '+';
			}
			else {
				ans -= a[j + 1]-'0';
				b[j] = '-';
			}
		}
		if (ans == 7) {
			for (i = 0; i < 3; i++) {
				printf("%c", a[i]);
				printf("%c", b[i]);
				
			}printf("%c=7", a[3]);
				return 0;
		}

	}
		return 0;
}

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

using namespace std;

typedef long long LL;

int main() {
    LL v[3];
    scanf("%lld%lld%lld",&v[0],&v[1],&v[2]);
    if (v[0] % 2 == 0 || v[1] % 2 == 0 || v[2] % 2 == 0) return 0 * puts("0");
    sort(v,v+3);
    printf("%lld\n",v[0]*v[1]);

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,d;
    cin>>n>>d;
    cout <<(n+2*d)/(2*d+1)<<"\n";
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<vector>
#include<iostream>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
using namespace std;
#define rep2(x,from,to) for(long long (x)=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 1000000000000000
int c;
int d;
int ans;
int n;
int a[100004];
int main()
{
    cin>>n;
    rep(i,n)
    {
        cin>>c;
        while(c%2==0)
        {
            c/=2;
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

class UnionFind{
    vector<int> parent, rank, num;
public:
    UnionFind(int N=0){
        parent.resize(N);
        rank.resize(N);
        num.resize(N, 1);
        for(int i=0;i<N;i++){
            parent[i] = i;
        }
    }

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

    bool same(int x, int y){
        return find(x) == find(y);
    }

    int unite(int x, int y){
        int root_x = find(x);
        int root_y = find(y);
        if(root_x == root_y) return 0;
        int num_y = num[root_y];
        int num_x = num[root_x];
        if(rank[root_x] < rank[root_y]){
            parent[root_x] = root_y;
            num[root_y] += num[root_x];
        }
        else{
            if(rank[root_x] == rank[root_y]){
                rank[root_x]++;
            }
            parent[root_y] = root_x;
            num[root_x] += num[root_y];
        }
        return (long long)num_x * (long long)num_y;
    }
};

int main(){
    int N, M, u1, u2;
    cin >> N >> M;
    UnionFind uf(N);
    long long convenience = ((long long)N * (long long)(N-1)) / 2;
    vector<pair<int, int>> edges(M);
    vector<long long> inc(M, 0);
    for(int i=0;i<M;i++){
        cin >> u1 >> u2;
        edges.at(i).first = u1 -1;
        edges.at(i).second = u2 - 1;
    }

    for(int i=M-1;i>-1;i--){
        inc.at(i) = convenience;
        if(convenience <= 0) break;
        convenience -= uf.unite(edges.at(i).first, edges.at(i).second);
    }

    for(int i=0;i<M;i++){
        cout << inc.at(i) << endl;
    }
}

Measured memory_bytes: 4096
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;

int main(){
	int a,b;
	cin>>a>>b;
	
	if(a%2==1 && b%2==1) cout<<"Odd";
	else cout<<"Even";
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int ans=0;
		int a[]=new int[n*2];
		for(int i=0;i<n*2;i++) {
			a[i]=sc.nextInt();
		}
		Arrays.sort(a);
		for(int i=0;i<n*2;i+=2) ans+=a[i];
System.out.println(ans);
	}
}

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

int main(){

    int r,d,twth; cin>>r>>d>>twth;

    long long int sum=0,ans = twth;

    for(int i=1; i<=10; i++ ){

        sum = ans;

        ans = r * sum -d;

        cout<<ans<<endl;

    }

    return 0;

}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  long int sum=0;
  long int digit=0;
  long int m,s,d;
  scanf("%ld",&m);
  for(int i=0;i<m;i++){
    scanf("%ld %ld",&s,&d);
    digit+=d;
    sum+=s*d;}
  printf("%ld\n",digit-1+(sum-1)/9);

  return 0;
}


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

/*vector<int> p(n);
cin >> p[i]*/

int main(){

    int a, b, m;
    int ans=0, val_min=0;
    cin >> a >> b >> m;

    vector<int> p(a);
    vector<int> q(b);
    vector<int> val(m);
    vector<vector<int>> r(m, vector<int>(3));

    for(int i=0; i<a; i++) cin >> p[i];
    for(int i=0; i<b; i++) cin >> q[i];
    for(int i=0; i<m; i++) val[i] = 0;

    for (int i = 0; i < m; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> r[i][j];
        }
    }

    for(int i=0; i<m; i++){
        val[i] = (p[r[i][0]-1] + q[r[i][1]-1]) - r[i][2];
    }

    sort(p.begin(), p.end());
    sort(q.begin(), q.end());

    val_min = p[0] + q[0];

    for(int i=0; i<m; i++){
        val_min = min(val_min, val[i]);
    }

    cout << val_min << endl;

    return 0;
}

Measured memory_bytes: 6912
import sys

def solve():
    input = sys.stdin.readline
    N, A, B = map(int, input().split())
    H = [int(input()) for _ in range(N)]
    low = 0; high = 10 ** 20
    while high - low > 1:
        mid = (low + high) // 2
        explosion = B * mid
        direct = 0
        for h in H:
            if h - explosion > 0:
                direct += (h - explosion) // (A - B)
                if (h - explosion) % (A - B) > 0: direct += 1
        if direct <= mid: high = mid
        else: low = mid
    print(high)

    return 0

if __name__ == "__main__":
    solve()

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

bool unblc(string s,int &x,int &y){
  int n=s.size();
  x=-1;y=-1;
  for(int i=0;i<n-1;i++){
    if(s.at(i)==s.at(i+1)){
      x=i+1;y=i+2;
      return 1;
    }
  }
  for(int i=0;i<n-2;i++){
    if(s.at(i)==s.at(i+2)){
      x=i+1;y=i+3;
      return 1;
    }
  }
  return 0;
}

int main(){
  string s;
  cin >> s;
  int x,y;
  unblc(s,x,y);
  cout << x << " " << y << endl;
}

Measured memory_bytes: 512
#include<stdio.h>
int main(){
  long long n,i,j,c,ans=0;
  scanf("%lld",&n);
  for(i=2;i*i<n;i++){
    for(c=0;n%i==0;c++)n/=i;//printf("%lld\n",c);
    for(j=0;j*(j+1)/2<=c;j++);
    ans+=j-1;
  }//printf("%lld %lld\n",n,ans);
  if(n-1)ans++;
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 1732
function Main(input) {
 
	// 1行目がinput[0], 2行目がinput[1], …に入る
  input = input.split("\n");
  
  let a = parseInt(input[0].split(" ")[0]);
  let v = parseInt(input[0].split(" ")[1]);
  let b = parseInt(input[1].split(" ")[0]);
  let w = parseInt(input[1].split(" ")[1]);
  let t = parseInt(input[2]);
  
  if (w - v >= 0) {
   	console.log("NO");
    return;
  }
  
  let delta_p = Math.abs(a - b);
  let delta_v = v - w;
  
  if (delta_p <= delta_v * t) console.log("YES");
  else console.log("NO");
    
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29476
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#include <math.h>
#include <queue>
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;

int main() {
    double d, t, s;
    cin >> d >> t >> s;
    if(d/s<=t) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3108
import java.util.HashMap;
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		HashMap<Integer,Integer>hm = new HashMap<Integer,Integer>();

		int n = sc.nextInt();
		
		for(int i = 1; i <= n ; i++) {
			int a = sc.nextInt();
			hm.put(a, i);
		}
		for(int i = 1 ; i <= n ;i++) {
			int ans = hm.get(i);
			System.out.println(ans);
		}
		
			}

}


Measured memory_bytes: 75376
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380


int main()
{
	cout << fixed << setprecision(10);

	LLI n;
	cin >> n;

	if (n == 1)
	{
		cout << 'a';
		return 0;
	}
	vector<char> c;
	while (0 < n)
	{
		c.push_back((n - 1) % 26 + 'a');
		if (n == 26)break;
		n = (n - 1) / 26;
	}
	REP(i, c.size())
	{
		cout << c[c.size() - i - 1];
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>
int main(void){
  int n,l=1,x;
  for(scanf("%d",&n);l<=n;l++){
    x=l;
    if(x%3==0)printf(" %d",l);
    else {
      for(;x;x/=10) { 
        if(x%10==3){
          printf(" %d",l);
          break;
        }
      }
    }
  }
  puts("");
  return 0;
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
#define ALL(x) (x).begin(),(x).end()
#define PB push_back
#define MP make_pair
#define Mod 998244353
#define MOD 1000000007
using namespace std;
using lint = long long;
using vi = vector<lint>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<lint, lint>;

// cout << fixed << setprecision(12)

lint modpow(lint a, lint n, lint m = MOD){
  lint ans = 1;
  while(n>0){
    if(n%2==1) ans *= a; 
    ans %= m;
    a *= a; 
    a %= m;
    n /= 2;
  }
  return ans;
}

lint inv(lint a, lint m = MOD){
  return modpow(a, m-2, m);
}

///////////////////////////////////

int main(){
  lint a,b,c,d;cin>>a>>b>>c>>d;
  cout << max(a*c, max(a*d, max(b*c, b*d))) << endl;
}



Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include<cstdio>

#define for(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
// #define ALLR(obj) (obj).rbegin(), (obj).rend()
#define BIT(n) (1LL << (n))

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int s;
  cin >> s;
  
  set<int> st;
  st.insert(s);
  
  int top = s;
  int m = 1;
  
  while(1) {
    ++m;
    
    if(top%2 == 0) {
      top = top/2;
    } else {
      top = 3*top + 1;
    }
     
    if (st.count(top)) {
      cout << m;
      break;
    }
    
    st.insert(top);
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define int ll
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
bool rever(int a,int b) { return a>b; }
int fpow(int b,int p,int m)
{
	if(p==0) return 1;
	int t=fpow(b,p/2,m);
	if(p%2) return t*t%m*b%m;
	return t*t%m;
}
int fpow(int b,int p)
{
	if(p==0) return 1;
	int t=fpow(b,p/2);
	if(p%2) return t*t*b;
	return t*t;
}

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int a,b; cin>>a>>b;
	cout<<a-b+1<<"\n";
	return 0;
}










Measured memory_bytes: 256
import java.util.Scanner;

//Rotation of a Pattern
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[][] s = new char[8][8];
		for(int i=0;i<8;i++)s[i]=sc.next().toCharArray();
		for(int r=90;r<=270;r+=90){
			System.out.println(r);
			char[][] t = new char[8][8];
			for(int i=0;i<8;i++){
				for(int j=0;j<8;j++)t[i][j]=s[7-j][i];
				System.out.println(new String(t[i]));
			}
			s = t;
		}
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <sstream>
#include <vector>

struct Card{
    char mark;
    int id;
    int pos;
};

void swap(Card& a, Card& b)
{
    Card tmp;
    tmp = a;
    a = b;
    b = tmp;
}

int partition(std::vector<Card>& A, int p, int r)
{
    int x = A[r].id;
    int i = p - 1;
    for(int j = p; j < r; j++){
	if(A[j].id <= x){
	    i = i + 1;
	    swap(A[i], A[j]);
	}
    }
    swap(A[i+1], A[r]);
    return i + 1;
}

void quicksort(std::vector<Card>& A, int p, int r){
    if(p < r){
	int q = partition(A, p, r);
	quicksort(A, p, q-1);
	quicksort(A, q+1, r);
    }
}

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

    std::vector<Card> A(n);
    for(int i = 0; i < n; i++){
	std::cin >> A[i].mark;
	std::cin >> A[i].id;
	A[i].pos = i;
    }
    quicksort(A, 0, n-1);

    std::stringstream ss;
    bool flag = true;
    Card prev;
    for(int i = 0; i < n; i++){
	ss << A[i].mark << " " << A[i].id << std::endl;
	if(i > 0 && prev.id == A[i].id && prev.pos > A[i].pos) flag = false;
	prev = A[i];
    }
    if(flag){
	std::cout << "Stable" << std::endl;
    }else{
	std::cout << "Not stable" << std::endl;
    }
    std::cout << ss.str();
}



Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin>>n;
  vector<int>x(n),y(n),num(n);
  for(int i=0;i<n;i++){
    cin>>x[i]>>y[i];
    num[i]=i;
  }
  double kyori=0;
  int count=1;
  do{
    for(int i=0;i<n-1;i++){
      kyori+=sqrt((x[num[i+1]]-x[num[i]])*(x[num[i+1]]-x[num[i]])+(y[num[i+1]]-y[num[i]])*(y[num[i+1]]-y[num[i]]));
    }
  }while(next_permutation(num.begin(),num.end()));
  for(int i=n;i>=1;--i){
    count*=i;
  }
  double kotae=kyori/(double)count;
  cout<<fixed<<setprecision(12)<<kotae<<endl;
  return 0;
}

Measured memory_bytes: 3812
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define int long long

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)
#define rrep(i,x) for(int i=(int)x-1;i>=0;--i)
#define rrep1(i,x) for(int i=(int)x;i>=1;--i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}

constexpr int inf = 1e9;
constexpr ll linf = 3e18;
constexpr double eps = 1e-9;

struct UF {
    vi data;
    void init(int n)
    {
        data.resize(n);
        fill(all(data), -1);
    }
    int root(int x)
    {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    void unite(int x, int y)
    {
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (size(x) < size(y)) swap(x, y);
        data[x] += data[y];
        data[y] = x;
    }
    bool same(int x, int y)
    {
        return root(x) == root(y);
    }
    int size(int x)
    {
        return -data[root(x)];
    }
    bool is_root(int x)
    {
        return x == root(x);
    }
};

signed main()
{
    int n, m; cin >> n >> m;

    UF uf;
    uf.init(n+2);

    vpii edges(m);
    rep(i, m) {
        int a, b; cin >> a >> b;
        --a, --b;
        edges[i] = pii(a, b);
    }

    vi ans(m+5);
    int a = n * (n - 1) / 2;

    for (int i = m - 1; i >= 0; --i) {
        pii edge = edges[i];
        ans[i] = a;
        if (!uf.same(edge.fst, edge.scd)) {
            a -= uf.size(edge.fst) * uf.size(edge.scd);
            uf.unite(edge.fst, edge.scd);
        }
    }

    rep(i, m) {
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 4480
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int sum = 0;
        int[] p = new int[n];
        int max = 0;
        for(int i=0;i<n;i++){
            p[i] = Integer.parseInt(sc.next());
            max = Math.max(p[i],max);
            sum+=p[i];
        }
        System.out.println(sum-max/2);
        sc.close();
    }
    
}

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

int main(){
    int n;
    string s;
    cin >> n;
    getline(cin, s);
    for(int i=0; i < n; i++){
        getline(cin, s);
        while(true){
            string::size_type index = s.find("Hoshino");
            if(index == string::npos) break;
            else s.replace(index, 7, "Hoshina");
        }
        cout << s << endl;
    }
}

Measured memory_bytes: 1208
open String
let rec iter a b f = if a >= b then [] else let v = f a in v :: iter (a+1) b f
let check a b =
  iter 0 (length a) (fun i -> a.[i] = '?' || a.[i] = b.[i])
  |> List.fold_left (&&) true
let () =
  Scanf.scanf "%s %s" @@ fun s' t ->
  let s'_len, t_len = length s', length t in
  iter 0 (s'_len-t_len+1) (fun i ->
    if check (sub s' i t_len) t then
      sub s' 0 i ^ t ^ sub s' (i+t_len) (s'_len-i-t_len)
      |> map (function '?' -> 'a' | c -> c)
      |> fun s -> Some s
    else
      None)
  |> List.fold_left (fun r -> function None -> r | Some s -> s) "UNRESTORABLE"
  |> print_endline

Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};

int main(){
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	int now = 1;
	int cnt = 0;
	vector<int> num;
	rep(i,n){
		if(now==s[i]-'0') cnt++;
		else{
			num.push_back(cnt);
			cnt = 1;
			now = 1 - now;
		}
	}
	num.push_back(cnt);
	if(num.size()%2==0) num.push_back(0);

	vector<int> sum(num.size()+1);
	sum[0] = 0;
	rep(i, num.size()){
		sum[i+1] = sum[i] + num[i];
	}

	int tmp = 0;
	int add = 2*k+1;
	int ans = 0;

	for(int i = 0; i < num.size(); i+=2){
		int left = i;
		int right = min(i+add, (int)num.size());

		tmp = sum[right] - sum[left];
		chmax(ans, tmp);
	}

	cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

int N;
int A[3];
double memo[310][310][310];

double func(int a, int b, int c){
    if(memo[a][b][c] >= 0){
        return memo[a][b][c];
    }

    if(a == 0 && b == 0 && c == 0)
        return 0.0;

    double ret = N;
    if(a > 0)
        ret += a * func(a-1, b, c);
    if(b > 0)
        ret += b * func(a+1, b-1, c);
    if(c > 0)
        ret += c * func(a, b+1, c-1);

    ret *= 1/(double)(a+b+c);

    return memo[a][b][c] = ret;
}

int main(){
    cin >> N;
    REP(i,N){
        int a;
        cin >> a;
        A[a-1] += 1;
    }


    REP(i,310){
        REP(j,310){
            REP(k,310){
                memo[i][j][k] = -1;
            }
        }
    }

    //memo[0][0][0] = 0;
    //memo[1][0][0] = N;
    double ans = 0;
    ans = func(A[0], A[1], A[2]);
    printf("%.15lf\n", ans);
    return 0;
}


Measured memory_bytes: 233088
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a = input().split()
    a = list(map(lambda x: x.capitalize(), a))
    a,b,c = a
    print(a[0]+b[0]+c[0])
    return

#B
def B():
    a = II()
    b = II()
    if a > b:
        print("GREATER")
    if a < b:
        print("LESS")
    if a == b:
        print("EQUAL")
    return

#C
def C():
    II()
    a = LI()
    def f(suma, b):
        for i in a[1:]:
            if suma * (suma + i) < 0:
                suma += i
                continue
            b += (abs(suma + i) + 1)
            suma = (-1 * (suma > 0)) or 1
        return b

    if a[0] == 0:
        ans = min(f(1, 1), f(-1, 1))
    else:
        ans = min(f(a[0], 0), f(1 * (a[0] < 0) or - 1, abs(a[0]) + 1))
    print(ans)
    return

#D
def D_():
    s = S()
    for i in range(len(s) - 1):
        if s[i] == s[i+1]:
            print(i + 1, i + 2)
            return
    for i in range(len(s) - 2):
        if s[i] == s[i + 2]:
            print(i + 1, i + 3)
            return
    print(-1, -1)

def D():
    x, y = LI()
    a = abs(x - y)
    if a <= 1:
        print("Brown")
    else:
        print("Alice")
    return


#Solve
if __name__ == '__main__':
    D()


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

using namespace std;

long long int gcd(long long int x, long long int y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

int main(){
    long long int N,div;
    cin >> N;
    vector<long long int> A(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
    }

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

    div = A[N-1];

    for(int i=N-2;0<=i;i--){
        div = gcd(div,A[i]);
    }

    cout << div << endl;
}

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// テーブルを作る前処理
const int MAX = 510000;
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 COM(ll n, ll 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() {
	int n,k;
	cin >> n >> k;

    vector<int> a(n);
    REP(i,n) cin >> a[i];

    vector<ll> sum_a(n+1,0);
    vector<ll> sum_b(n+1,0);
    REP(i,n){
        sum_a[i+1] = sum_a[i]+a[i];
        sum_b[i+1] = sum_b[i]+max(0,a[i]);
    }

    ll ans = 0;
    REP(i,n-k+1){
//        cout << sum_a[i+k]-sum_a[i] << ":" << sum_b[i]-sum_b[0] << " " << sum_b[n]-sum_b[i+k] << endl;
        chmax(ans,max(0LL,sum_a[i+k]-sum_a[i])+(sum_b[i]-sum_b[0])+(sum_b[n]-sum_b[i+k]));
    }

    pl(ans)

	return 0;
}


Measured memory_bytes: 2176
#include <iostream>

using namespace std;

int main(){
    int a,b,c,d;
    
    cin >> a >> b >> c >> d;
    while(1){
        c -= b;
        if(c <= 0){
            cout << "Yes" << endl;
            break;
        }

        a -= d;
        if(a <= 0){
            cout << "No" << endl;
            break;
        }
    }
    return 0;
}

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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


int main(){
  int n;
  scanf("%d", &n);

  if (n == 1) printf("Hello World\n");
  else {
    int a, b;
    scanf("%d", &a);
    scanf("%d", &b);
    printf("%d\n", a + b);
  }
}


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

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

	string s;
	int k;

	cin >> s;
	cin >> k;

	if(s.length()<=50)
	{
		set <string> S;
		for(int i=0;i<s.length();i++)
		{
			string t;
			for(int j=i;j<s.length();j++)
			{
				t += s[j];
				S.insert(t);
			}
		}

		int turn = 1;
		for(auto it : S)
		{
			if(k==turn)
			{
				cout << it << '\n';
				break;
			}
			turn++;
		}
	}
	else
	{
		set <string> S;
		for(int i=0;i<s.length();i++)
		{
			string t;
			for(int j=0;j<10;j++)
			{
				if(i+j>=s.length())
				{
					break;
				}
				t+=s[i+j];
				S.insert(t);
			}
		}

		int turn = 1;
		for(auto it : S)
		{
			if(k==turn)
			{
				cout << it << '\n';
				break;
			}
			turn++;
		}		
	}
	return 0;	
}


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

using namespace std;
using ll = long long;
using vi = vector<int>;
using ii = pair<int, int>;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	ll happiness = 0;
	while(n >= 500){
		happiness += 1000;
		n -= 500;
	}
	while(n >= 5){
		happiness += 5;
		n -= 5;
	}
	cout << happiness << endl;
}




Measured memory_bytes: 3528
using System;

namespace _073_SurfaceAreaofQuadrangularPyramid
{
	class Program
	{
		static void Main ( string[] args )
		{
			string inputSide;
			string inputHeight;

			while ((inputSide = Console.ReadLine ()) != "0" &&
				(inputHeight = Console.ReadLine ()) != "0")
			{
				double side = double.Parse (inputSide);
				double height = double.Parse (inputHeight);

				double triangleHeight = Math.Sqrt ((side / 2) * (side / 2) + height * height);

				double result = (side * side) + (side * triangleHeight * 4 / 2);

				Console.WriteLine (result);
			}
		}
	}
}

Measured memory_bytes: 9304
#include <stdio.h>
#define MAX 10^12


long long int A,B,K;

int main(int argc, char const *argv[])
{
	scanf("%lld", &A);
	scanf("%lld", &B);
	scanf("%lld", &K);

	if (A <= K)
	{
		K = K-A;
		A = 0;

		if (B <= K)
		{
			B = 0;
		}

		else{
			B = B-K;
			K = 0;
		}
	}

	else{
		A = A-K;
		K = 0;
	}

	printf("%lld %lld", A, B);
	return 0;
}


Measured memory_bytes: 128
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    A,V = map(int,input().split())
    B,W = map(int,input().split())
    T = int(input())

    tar = (V - W) * T
    diff = abs(B - A)

    res = 'NO'

    if tar > 0:
        if tar >= diff:
            res = 'YES'


    print(res)



main()


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





class Primes {
public:
	int size;
	vector<int> v, primes;
	Primes(int _size) : size(_size), v(_size,0), primes(){
		int sqrtsize = (int)sqrt((double)_size);
		
		for ( int i = 2; i < size; i++ ){
			if ( v[i] )
				continue;
			primes.push_back(i);
			if ( i <= sqrtsize )
				for ( int j = i*i; j < _size; j+=i )
					v[j] = 1;
		}
	}
	
	// map<prime,pow>
	map<int,int> factor(ll x){
		map<int,int> m;
		for ( auto it : primes ){
			int prime = it;
			if ( x < prime )
				break;
			
			int count = 0;
			while ( x % prime == 0 ){
				x /= prime;
				count++;
			}
			if ( count )
				m[prime] = count;
		}
		if ( x != 1 )
			m[x] = 1;
		return m;
	}
	
	
	vector<pair<int,int>> factorv(ll x){
		auto m = factor( x );
		vector<pair<int,int>> v;
		for ( auto it : m ){
			v.push_back({it.first,it.second});
		}
		return v;
	}
	
	// 約数を求める
	vector<int> divisor( ll x ){
		auto v = factorv( x );
		vector<int> div;
		divisor2( div, v, 0, 1 );
		sort(div.begin(), div.end());
		return div;
	}
	
	int divisor2( vector<int> &div, vector<pair<int,int>> &v, size_t i, int mul ){
		for ( int j = 0; j <= v[i].second; j++ ){
			if ( i == v.size()-1 ){
				div.push_back(mul);
			}
			else {
				divisor2( div, v, i+1, mul );
			}
			mul *= v[i].first;
		}
	}
	
	
};


ll N, K;

int main(){
	cin >> N >> K;
	
	vector<ll> A(N);
	ll Asum = 0;
	for ( int i = 0; i < N; i++ ){
		cin >> A[i];
		Asum += A[i];
	}
	
	Primes p(50*1000);
	
	// 回答は、A の合計の約数になっているはず
	auto d = p.divisor(Asum);
	sort(d.begin(),d.end(),greater<int>());
	
	
	for ( auto result : d ){
		vector<ll> diff(N);
		
		// K回以下の操作でできるか調べる
		// A を result で割って、余りをソート
		for ( int i = 0; i < N; i++ ){
			diff[i] = A[i] % result;
		}
		sort( diff.begin(), diff.end() );
		
		//cout << result << endl;
		//for ( int j = 0; j < N; j++ )
		//	cout << "diff: " << diff[j] << endl;
		
		vector<ll> acc(N+1);
		ll diffsum = 0;
		for ( int i = 0; i < N; i++ ){
			acc[i] = diffsum;
			diffsum += diff[i];
		}
		acc[N] = diffsum;
		
		// diff[0..i-1] <- -1 
		// diff[i..N-1] <- +1 
		for ( int i = 1; i < N; i++ ){
			if ( acc[i] <= K && (N-i)*result - (acc[N]-acc[i]) <= K ){
				
				cout << result << endl;
				return 0;
			}
		}
	}
	
	return 0;
}



Measured memory_bytes: 512
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    A = iss()
    B = iss()

    ret = 0
    for a, b in zip(A, B):
        if a != b: ret+=1
    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 10384
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i = 0; i < n; i++) cin >> v[i];
    int m;
    cin >> m;
    vector<int> w(m);
    for(int i = 0; i < m; i++) cin >> w[i];
    vector<int> result;
    set_symmetric_difference(v.begin(), v.end(), w.begin(), w.end(), back_inserter(result));
    for(int i = 0; i < result.size(); i++) cout << result[i] << endl;
    return 0;
}




Measured memory_bytes: 6464
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include<iostream>
#include<vector>
using namespace std;
int main()
{
    int n,k;
    while(cin>>n>>k)
    {
        int q[10];
        int qq[100];
//        int mi=100;
        memset(qq,0,sizeof(qq));
        for(int i=1; i<=k; i++)
        {
            cin>>q[i];
            qq[q[i]]=1;
        }
        int sum=0;
        int a[6];
//        cout<<n<<endl;
        for(int j=n; j<=100000; j++)
        {
            int i=j;
            a[0]=i/10000;
            i%=10000;
            a[1]=i/1000;
            i%=1000;
            a[2]=i/100;
            i%=100;
            a[3]=i/10;
            a[4]=i%10;

//            if(i=10000)
//                cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
            int flag=1;
            int vis=1;
            for(int i=0;i<=4;i++)
            {
                if(a[i]!=0)
                {
                    vis=0;
                }
                if(vis==0)
                {
                    if(qq[a[i]]==1)
                        flag=0;
                }
            }
            if(flag)
            {
                sum=j;
                break;
            }
        }
        cout<<sum<<endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <utility>
#include <bitset>

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

using namespace std;

int main () {
    int n, m;
    cin >> n >> m;
    if (max(n,m) > 9 || min(n,m) < 1 ){
        cout << -1 << endl;
        return 0;
    }
    cout << n * m << endl;
    return 0;
}

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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (ll)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) {
        ll d = euclid(b, a % b, y, x);
        return y -= a / b * x, d;
    }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1)
            ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1);
        return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e)
            return Mod(1);
        Mod r = *this ^ (e / 2);
        r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int main() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin.exceptions(cin.failbit);

    for (;;) {
        int n, m;
        cin >> n >> m;
        if (!n)
            break;

        vector<int> tstart(n), tend(n);
        vector<string> tname(n);

        rep(i, 0, n) {
            int l;
            cin >> tname[i] >> l >> tend[i];
            tstart[i] = tend[i] - l + 1;
        }

        rep(i, 0, m) {
            int y;
            cin >> y;
            bool ok = false;
            rep(i, 0, n) {
                if (tstart[i] <= y && y <= tend[i]) {
                    cout << tname[i] << " " << (y - tstart[i] + 1) << endl;
                    ok = true;
                }
            }
            if (!ok)
                cout << "Unknown" << endl;
        }
    }
}



Measured memory_bytes: 3288