akhauriyash/Code-Regression huggingface dataset:
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

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

	void run() {
		Scanner sc = new Scanner(System.in);
		long A = sc.nextLong();
		long B = sc.nextLong();
		if (A == B) {
			System.out.println("0");
			return;
		}
		// A-K=-(B-K)
		// (A+B)/2=K

		if (A % 2 != B % 2) {
			System.out.println("IMPOSSIBLE");
			return;
		}

		long K = (A + B) / 2;
		if (Math.abs(A - K) == Math.abs(B - K)) {
			System.out.println(K);
			return;
		}
		System.out.println("IMPOSSIBLE");
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}

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

using namespace std;
using ll = long long;

#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int a[100005];
bool used[200005];
int main() {
    int n, m;
    cin >> n >> m;
    rep(i, m) cin >> a[i];
    reverse(a, a + m);
    rep(i, m) {
        if (!used[a[i]]) {
            cout << a[i] << endl;
            used[a[i]] = 1;
        }
    }
    rep(i, n + 1) if (i) {
        if (!used[i]) cout << i << endl;
    }
    return 0;
}

Measured memory_bytes: 3672
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    N = int(input())
    S = input()
    res = S[0]
    for i in range(1, N):
        if res[-1] != S[i]:
            res += S[i]
    print(len(res))

if __name__ == '__main__':
    main()

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

int main(){
    int h,w;

    while(1){
        cin >> h >> w;
        if(h == 0 && w == 0) break;
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 3084
#include "bits/stdc++.h"
using namespace std;
int main(){
    stack<int> s;
    string c;
    int a,b ;
    while(cin >> c){
        if(c[0] == '+'){
            a = s.top();s.pop();
            b = s.top();s.pop();
            s.push(a+b);
        }
        else if(c[0] == '-'){
            a = s.top();s.pop();
            b = s.top();s.pop();
            s.push(b-a);
        }
        else if(c[0] == '*'){
            a = s.top();s.pop();
            b = s.top();s.pop();
            s.push(a*b);
        } else{
            s.push(atoi(c.c_str()));
        }
    }
    cout << s.top() << endl;
    return 0;
}


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

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

int main()
{
    int N, X;
    cin >> N >> X;
    vector<int> xs(N);
    for (int i = 0; i < N; i++) cin >> xs[i];
    int result = abs(X - xs[0]);
    for (int x : xs) {
        result = gcd(result, abs(X - x));
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>
#include <bitset>
#include <sstream>
#include <cassert>
#include <time.h>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}
void printvec (vec &v) {
    Rep (i, (ll)v.size()) {
        cout << v[i] << " \n"[i+1 == (ll)v.size()];
    }
}

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

    ll H, W, K;
    cin >> H >> W >> K;
    vector<string> c(H);
    Rep (i, H) {
        cin >> c[i];
    }

    ll ans = 0;
    Rep (maskh, 1<<H) {
        Rep (maskw, 1<<W) {
            ll cnt = 0;
            Rep (i, H) {
                Rep (j, W) {
                    if ((maskh>>i)&1 and (maskw>>j)&1 and c[i][j] == '#') cnt++;
                }
            }
            if (cnt == K) ans++;
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 3656
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <map>
#include <string>
#include <queue>
#include <utility>
#include <vector>

using namespace std;

typedef pair<int, int> P;

long long n, a, b, c;
int s[110000];
char ans[110000];

void dfs(int i, int p, int q, int r) {
  if (i == n) {
    cout << "Yes" << endl;
    for (int j = 0; j < n; j++) {
      cout << ans[j] << endl;
    }
    exit(0);
  }
  
  if (s[i] == 0) {
    if (p) {
      ans[i] = 'B';
      dfs(i+1, p-1, q+1, r);
    }
    if (q) {
      ans[i] = 'A';
      dfs(i+1, p+1, q-1, r);
    }
  }
  if (s[i] == 1) {
    if (q) {
      ans[i] = 'C';
      dfs(i+1, p, q-1, r+1);
    }
    if (r) {
      ans[i] = 'B';
      dfs(i+1, p, q+1, r-1);
    }
  }
  if (s[i] == 2) {
    if (r) {
      ans[i] = 'A';
      dfs(i+1, p+1, q, r-1);
    }
    if (p) {
      ans[i] = 'C';
      dfs(i+1, p-1, q, r+1);
    }
  }
}


int main(void) {
  cin >> n >> a >> b >> c;
  
  for (int i = 0; i < n; i++) {
    string str;
    cin >> str;
    if (str == "AB") s[i] = 0;
    if (str == "BC") s[i] = 1;
    if (str == "AC") s[i] = 2;
  }
  
  dfs(0, a, b, c);
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 13500
#include <iostream>

using namespace std;

int main()
{
    string inp;

    cin>>inp;

    if(inp == "Sunny")
        cout<<"Cloudy";
    else if(inp == "Cloudy")
        cout<<"Rainy";
    else if(inp == "Rainy")
        cout<<"Sunny";


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <queue>
#include <map>
#include <list>
//#include <bits/stdc++.h>


using namespace std;

#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
typedef long long ll;

int main(){
    int s, w;
    cin >> s >> w;
    if(w >= s)cout << "unsafe" << endl;
    else cout << "safe" << endl;
    return 0;
}

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

int main() {
    int N, M, C;
    cin >> N >> M >> C;
    int b[M];
    int a[N][M];
    for (int i = 0; i < M; i++)
        cin >> b[i];
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            cin >> a[i][j];
        }
    }
    int ans = 0;
    for (int i = 0; i < N; i++) {
        int sum = 0;
        for (int j = 0; j < M; j++) {
            sum += a[i][j] * b[j];
        }
        if (sum + C > 0)
            ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// G++ MACRO.CPP -STD=C++17
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
 
#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
 
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
 
#define FOREACH(x,a) for(auto& (x) : (a) )
 
#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])
 
#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl
 
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) if(1){for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl;}
 
#define ALL(obj) (obj).begin(),(obj).end()
 
#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define EN(x) if(1){cout<<#x<<endl;return 0;}
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
 
template <class T = ll>
T IN(){T x;cin>>x;return (x);}
 
template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
    seco.resize(head);
    VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
  VECCIN(head);
  VT2(move(tail)...);
}
 
template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
  seco[head]=IN();
  VT3(head,move(tail)...);
}
 
#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc
 
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision; // cpp_int
 
#define P pair<ll,ll>
#define V vector<ll>
#define M map<ll,ll>
#define S set<ll>
 
#define pb(a) push_back(a)
#define mp make_pair
 
int main(){
 
  CIN(a,b);if(a==b)EN(Draw);
  if(a==1)EN(Alice);if(b==1)EN(Bob);
  SANKOU(a>b,Alice,Bob);
 
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int n, ans = 0;
	while (cin >> n) {
		ans = 0;
		if (cin.eof())
			return 0;
		for (int a = 0; a <= 9; a++) {
			for (int b = 0; b <= 9; b++) {
				for (int c = 0; c <= 9; c++) {
					for (int d = 0; d <= 9; d++) {
						if (a + b + c + d == n)
							ans++;
					}
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end() 
#define rep(i, K, N)  for(long long int i = K; i < N; i++)
#define ll long long int
#define PP 1000000007
using namespace std;

ll N, M, K, sum = 0, Ans = 0;

int main(){
cin >> N >> M >> K;
vector<ll> A(N + 1);
vector<ll> B(M + 1);

rep(i, 1, N + 1){
  
  ll a;cin >> a;

  sum += a;A[i] = sum;

}

sum = 0;

rep(i, 1, M + 1){
  
  ll b;cin >> b;

  sum += b;B[i] = sum;

}

rep(i, 0, N + 1){
  
  if(A[i] > K)break;

  auto I = upper_bound(ALL(B), K - A[i]);

  ll j = I - B.begin() - 1;

  Ans = max(i + j, Ans);

}

cout << Ans;

}

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


void solve(long long N, std::vector<long long> a){
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (a[i] % 2 == 1 && (i + 1) % 2 == 1) {
            ans++;
        }
    }
    cout << ans << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


Measured memory_bytes: 3692
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstdint>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;

typedef pair<int, int> P;

bool ps1(const P &element1, const P &element2)
{ //first昇順
	return element1.first < element2.first;
}
bool ps2(const P &element1, const P &element2)
{ //first降順
	return element1.first > element2.first;
}
bool ps3(const P &element1, const P &element2)
{ //second昇順
	return element1.second < element2.second;
}
bool ps4(const P &element1, const P &element2)
{ //second降順
	return element1.second > element2.second;
}
int digits(int n)
{
	int count = 0;

	while (n > 0)
	{
		n /= 10;

		count++;
	}
	return count;
}
int digit(int n)
{

	int ans = 0;
	while (n > 0)
	{
		ans += n % 10;
		n /= 10;
	}
	return ans;
}
ll combination(ll n, ll r)
{
	if (r * 2 > n)
		r = n - r;
	ll dividend = 1;
	ll divisor = 1;
	for (ll i = 1; i <= r; ++i)
	{
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}
int GCD(int x, int y)
{
	return x ? GCD(y % x, x) : y;
}
vector<int> divisor(int n)
{
	vector<int> value;
	FOR(i, 1, pow(n, 0.5) + 1)
	{
		if (i <= sqrt(n))
		{
			if (n % i == 0)
			{
				value.push_back(i);
				if (i * i != n)
				{
					value.push_back(n / i);
				}
			}
		}
	}
	return value;
}

int main()
{
	int n;
	cin>>n;
	string s,t;
	cin>>s>>t;
	int ss=s.size();
	int ts=t.size();
	
		int size=0;
		rep(i,ts+1){
			string tmp=s;
			tmp+=t.substr(ts-i,i);
			int tms=tmp.size();
			if(tmp.substr(0,n)==s&& tmp.substr(tms-n,n)==t){
				size=tms;
				break;
			}
		}
		cout<<size<<endl;
	
}


Measured memory_bytes: 256
import sys

s = input()
n = len(s)

# xxとxoxだけ見ればいい

for i in range(n - 1):
    if s[i] == s[i + 1]:
        print(i + 1, i + 2)
        sys.exit()

for i in range(n - 2):
    if s[i] == s[i + 2]:
        print(i + 1, i + 3)
        sys.exit()

print(-1, -1)

Measured memory_bytes: 9232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int M = 1e9+7;

int n, k;
ll ans = 1;
int l_neg = -1, l_pos = -1, r_neg = -1, r_pos = -1;

bool cmp(ll a, ll b)
{
	return abs(a) < abs(b);
}

ll calc(vector<ll> a)
{
	ll temp = 1;
	for(int i = n - k; i < n; i++)
		temp = (temp * a[i]) % M;
	return temp;
}

bool v_cmp(vector<ll> a, vector<ll> b)
{
	ll sum1 = 0, sum2 = 0;
	for(int i = n - k; i < n; i++){
		sum1 += abs(a[i]);
		sum2 += abs(b[i]);
	}
	return sum1 > sum2;
}

int main() {
	scanf("%d%d", &n, &k);
	vector<ll> a(n, 0);
	for(int i = 0; i < n; i++) scanf("%lld", &a[i]);
	sort(a.begin(), a.end(), cmp);

	for(int i = n - k; i < n; i++){
		ans = (ans * a[i]) % M;
		if(r_pos == -1 && a[i] > 0) r_pos = i;
		if(r_neg == -1 && a[i] < 0) r_neg = i;
	}
	for(int i = n - k - 1; i >= 0; i--){
		if(l_pos == -1 && a[i] > 0) l_pos = i;
		if(l_neg == -1 && a[i] < 0) l_neg = i;
	}
	
	if(ans < 0 && n != k){
		if(r_pos == -1){
			if(l_pos == -1){
				ans = 1;
				for(int i = 0; i < k; i++)
					ans = (ans * a[i]) % M;
			}
			else {
				swap(a[l_pos], a[r_neg]);
				ans = calc(a);
			}
		}
		else {
			if(l_neg == -1){
				swap(a[l_pos], a[r_neg]);
				ans = calc(a);
			}
			else if(l_pos == -1){
				swap(a[l_neg], a[r_pos]);
				ans = calc(a);
			}
			else {
				vector<ll> c1 = a;
				vector<ll> c2 = a;
				swap(c1[l_neg], c1[r_pos]);
				swap(c2[l_pos], c2[r_neg]);
				if (a[l_neg]*a[r_neg] > a[l_pos]*a[r_pos]) ans = calc(c1);
				else ans = calc(c2);
			}
		}
	}
	printf("%lld\n", (ans + M) % M);
	return 0;
}


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

typedef long long ll;

int n, q, a[100010], b[100010];
ll x[100010], l;
int st[20][100010],rst[20][100010];

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



    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> x[i];
    }
    cin >> l >> q;
    for(int i = 0; i < q; i++) {
            cin>> a[i] >> b[i];
            a[i] --;
            b[i] --;
    }

    for(int i = 0; i < 20; i++){
        for(int j = 0; j < 100010;j++){
            st[i][j] = n-1;
            rst[i][j] = 0;
        }
    }
    for(int i = 0; i < n; i++){
        st[0][i] = (upper_bound(x,x+n,x[i]+l)-x) -1;
        rst[0][i] = (lower_bound(x,x+n,x[i]-l)-x);
    }
    //cout<<endl;
    int tem = 2;
    for(int i = 1; i < 20; i++){
        for(int j = 0; j < n; j++){
            st[i][j] = st[i-1][st[i-1][j]];
            rst[i][j] = rst[i-1][rst[i-1][j]];
        }

        tem *= 2;
        if(tem >= n)break;
    }

    for(int i = 0; i < q; i++){
        int aa = a[i], bb = b[i];
        int ans = 0;
        if(aa < bb){
            for(int i = 19; i>=0; i--){
                if(st[i][aa] < bb){
                    aa = st[i][aa];
                    ans += pow(2,i);
                }
            }
        }
        else{
            for(int i = 19; i>=0; i--){
                if(rst[i][aa] > bb){
                    aa = rst[i][aa];
                    ans += pow(2,i);
                    //cout<<endl<<aa<<'#';
                }
            }
        }
        ans+=1;
        cout<<ans<<endl;
    }

    return 0;
}


Measured memory_bytes: 18048
#include <iostream>
#include <string>
using namespace std;
int main(void){
 string s;
 cin >> s;
 s[0] = '2';
 s[1] = '0';
 s[2] = '1';
 s[3] = '8';
 cout << s << "\n";
 
 return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
int n,m;
int a[2000000],b[2000000];
int main(void){
    while(1){
        scanf("%d%d",&n,&m);
        if(n+m==0) break;
        for(int i=0;i<2000000;i++)a[i]=b[i]=0;
        int h[2000]={0},w[2000]={0};
        for(int i=1;i<=n;i++){
            scanf("%d",&h[i]);
            h[i]+=h[i-1];
        }
        for(int i=1;i<=m;i++){
            scanf("%d",&w[i]);
            w[i]+=w[i-1];
        }
        //rep(i,m) printf("%d\n",w[i]);
        for(int i=1;i<=n;i++)
            for(int j=i;j<=n;j++)
                a[h[j]-h[i-1]]++;
        for(int i=1;i<=m;i++)
            for(int j=i;j<=m;j++)
                b[w[j]-w[i-1]]++;
        int ans=0;
        for(int i=0;i<2000000;i++)ans+=a[i]*b[i];
        printf("%d\n",ans);
    }
}



Measured memory_bytes: 17360
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=(a);i<=(b);++i)
#define rv(i,a,b) for(int i=(a);i>=(b);--i)
#define P pair<int,int>
using namespace std;
typedef long long LL;
const int M = 1200000;
const int inf = 0x3f3f3f3f;
int n,m,k;
P p[M];
int main() {
	cin>>n;
	int x,l;
	fo(i,1,n){
		cin>>x>>l;
		p[i]={x+l,x-l};
	}
	sort(p+1,p+1+n);
	int cnt=0;
	int bound=-inf;
	fo(i,1,n){
		if(p[i].second<bound) continue;
		++cnt;
		bound=p[i].first;
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
  int A,B,C=0;
  cin >> A >> B;
  if(A-B>=1){
    cout << A*2-1 << endl;
  }else if(B-A>=1){
    cout << B*2-1 << endl;
  }else{
    cout << A+B << endl;
  }
  return 0;
}

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

#define mx 200005
#define ll long long


char ch[mx];
ll besi[mx],kom[mx];
ll csum[mx],csum1[mx];
int n,m,k,ii;
ll mod;

ll bigmod(ll e,ll x)
{
    if(!x)return 1;
    ll p=bigmod(e,x/2);
    p=(p*p)%mod;
    if(x%2)p=(p*e)%mod;
    return p;
}

void func(ll val)
{
    int re=1;
    while(val)
    {
        int cnt=__builtin_popcount(val);
        re++;
        val%=cnt;
    }
    printf("%d\n",re);
}

void solve()
{
   scanf("%d%s",&n,ch);
   int cnt=0;
   for(int i=0;i<n;i++)
   {
       if(ch[i]=='1')cnt++;
   }
   for(int i=0;i<n;i++)
   {
       if(cnt>1)
       {
           mod=cnt-1;
           if(ch[i]=='1')kom[i]=bigmod(2,n-i-1);
       }

           mod=cnt+1;
           if(ch[i]=='1')besi[i]=bigmod(2,n-i-1);

   }
   if(cnt>1)
       for(int i=0;i<n;i++)
       {
           csum[i+1]=(csum[i]+kom[i])%(cnt-1);
       }

   if(cnt!=0)
       for(int i=0;i<n;i++)
       {
           csum1[i+1]=(csum1[i]+besi[i])%(cnt+1);
       }

   for(int i=0;i<n;i++)
   {
       if(ch[i]=='1')
       {
           if(cnt==1)
           {
               printf("0\n");
               continue;
           }
           mod=cnt-1;
           ll val=csum[n]-bigmod(2,n-i-1);
           val=(val+mod)%mod;
           func(val);
       }
       else
       {
           mod=cnt+1;
           ll val=csum1[n]+bigmod(2,n-i-1);
           val%=mod;
           func(val);
       }
   }
}

int main()
{
   //freopen("in.txt","r",stdin);
   //freopen("out.txt","w",stdout);
   int t=1;
   //scanf("%d",&t);
   while(t--)solve();
   return 0;
}


Measured memory_bytes: 10176
import java.util.Scanner;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    while(true){
      int a = sc.nextInt();
      int b = sc.nextInt();
      if(a == 0){
        break;
      }else{
        for(int i=0;i<a;i++){
          for(int j=0;j<b;j++){
            System.out.print("#");
          }
          System.out.println("");
        }
        System.out.println("");
      }
    }
    sc.close();
  }
}


Measured memory_bytes: 34744
#include<iostream>

using namespace std;

int main(){
    long long a,b,k,flg=0;
    cin >> a >> b >> k;
    if(k<=a){
        cout << a-k << " " << b << endl;
    }else if(k>a && k<=(a+b)){
        cout << 0 << " " << b+a-k << endl;
    }else{
        cout << 0 << " " << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
<?php


fscanf(STDIN, "%d %d %d", $N, $M, $C);
$b = explode(" ", trim(fgets(STDIN)));
$result=0;

for ($i=0; $i < $N; $i++) { 
	$sum=0;
	$input = explode(" ", trim(fgets(STDIN)));
	for ($j=0; $j < $M; $j++) { 
		$sum += $input[$j] * $b[$j];
	}
	if ($sum+$C>0) {
		$result++;
	}
}

echo $result;


Measured memory_bytes: 4728
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1 << 30;

using namespace std;

using ll = long long;
using P = tuple<int, int>;
using iarr = valarray<int>;

int main()
{
    vector<string> v(3);
    cin >> v[0] >> v[1] >> v[2];

    cout << 'A' << v[1][0] << 'C' << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 順列　do {} while(next_permutation(ALL(X)));
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main() {
  int n,m;
  cin >> n >> m;
  vi x(m),xsa(m-1);
  REP(i,m) {
    cin >> x[i];
  }
  sort(ALL(x));
  REP(i,m-1) {
    xsa[i]= x[i+1]-x[i];
  }
  sort(ALL(xsa));
  int ans=0;
  if(n<m) {
    REP(i,m-n) {
      ans+=xsa[i];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
n = int(input())
arr = sorted(list(map(int, input().split())))
res = 0
for i in range(0, n - 2):
	for j in range(i, n - 1):
		for k in range(j, n):
			if arr[i] + arr[j] > arr[k] and arr[i] != arr[j] and arr[j] != arr[k] and arr[i] != arr[k]:
 				res += 1
print(res)

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

int main(int argc, char const *argv[]) {
    int n, x;
    cin >> n >> x;
    vector<int> l(n);
    vector<int> d(n+10);
    REP(i,n) cin >> l[i];
    d[0] = 0;
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        d[i] = d[i-1]+l[i-1];
        if (d[i] <= x) ans++;
    }
    cout << ans+1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define PQ priority_queue
#define UM unordered_map
#define ALL(a) (a).begin(),(a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
const ll INF = (1ll << 60);
typedef pair<ll,ll> pii;
struct Edge{
  ll to,id;
  Edge(ll to,ll id):to(to),id(id){}
};
typedef vector<vector<Edge>> Graph;
typedef vector<pii> vpii;

ll f(ll a,ll b,ll c) {
  if(a==0||b==0||c==0) return INF;
  return max(a,max(b,c))-min(a,min(b,c));
}

int main() {
  ll H,W; cin>>H>>W;
  ll ans=INF;
  for(ll h=1;h<H;h++) ans=min(ans,f((W/2)*h,(W-W/2)*h,W*(H-h)));
  for(ll w=1;w<W;w++) ans=min(ans,f((H/2)*w,(H-H/2)*w,H*(W-w)));
  if(H%3==0||W%3==0) ans=0;
  if(H>=3) ans=min(ans,W);
  if(W>=3) ans=min(ans,H);

  cout<<ans<<endl;
}


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

int Or[4][3][10];
int n;
int b, f, r, v;

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> b >> f >> r >> v;
        if (b == 1) {
            if (f == 1) {
                Or[0][0][r - 1] += v;
            } else if (f == 2) {
                Or[0][1][r - 1] += v;
            } else if (f == 3) {
                Or[0][2][r - 1] += v;
            }
        } else if (b == 2) {
            if (f == 1) {
                Or[1][0][r - 1] += v;
            } else if (f == 2) {
                Or[1][1][r - 1] += v;
            } else if (f == 3) {
                Or[1][2][r - 1] += v;
            }
        } else if (b == 3) {
            if (f == 1) {
                Or[2][0][r - 1] += v;
            } else if (f == 2) {
                Or[2][1][r - 1] += v;
            } else if (f == 3) {
                Or[2][2][r - 1] += v;
            }
        } else if (b == 4) {
            if (f == 1) {
                Or[3][0][r - 1] += v;
            } else if (f == 2) {
                Or[3][1][r - 1] += v;
            } else if (f == 3) {
                Or[3][2][r - 1] += v;
            }
        }
    }
    
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 10; k++) {
                cout << " " << Or[i][j][k];
                
            }
            cout << endl;
            
        }
        
        if (i == 3) {
            
            return 0;
        } else {
            cout << "####################" << endl;
            
        }
        
    }
}



Measured memory_bytes: 3092
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


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

  ll ans;
  
  if(h%3==0 || w%3 == 0){
    ans = 0;
  }else{
    ans = min(h,w);
  }
  
  for(int i=0;i<h;i++){
    ll a = max(abs((ll)i*(w/2) - (ll)(h-i)*w), abs((ll)i*((w+1)/2) - (ll)(h-i)*w));
    ans = min(a,ans);
  }

  for(int i=0;i<w;i++){
    ll a = max(abs((ll)i*(h/2) - (ll)(w-i)*h), abs((ll)i*((h+1)/2) - (ll)(w-i)*h));
    ans = min(a,ans);
  }

  printf("%lld\n",ans);
  
  return 0;
}


Measured memory_bytes: 256
def get_int(): return int(input())
def get_float(): return float(input())
def get_line(): return input().split()
def get_lines(v): return [get_line() for _ in range(v)]
def get_int_line(): return list(map(int, get_line()))
def get_int_lines(v): return [get_int_line() for _ in range(v)]
def get_float_line(): return list(map(float, get_line()))
def get_float_lines(v): return [get_float_line() for _ in range(v)]

T, X = get_int_line()
print(T / X)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int sx = sc.nextInt();
		int sy = sc.nextInt();
		int tx = sc.nextInt();
		int ty = sc.nextInt();
		int w = tx - sx;
		int h = ty - sy;
		String ans = "";
		ans += ms('D', 1);
		ans += ms('R', w + 1);
		ans += ms('U', h + 1);
		ans += ms('L', w + 1);
		ans += ms('D', h);
		ans += ms('R', w);
		ans += ms('U', h + 1);
		ans += ms('L', w + 1);
		ans += ms('D', h + 1);
		ans += ms('R', 1);
		System.out.println(ans);
	}

	static String ms(char c, int num) {
		String ret = "";
		for (int i = 0; i < num; ++i) {
			ret += c;
		}
		return ret;
	}
}


Measured memory_bytes: 41416
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int MOD = 1e9 + 7;

map<pair<ll, ll>, ll> memo;
ll pow(ll a, ll b) {
  if (memo.count({a, b})) return memo[{a, b}];
  ll r = 1;
  for (ll i = 0; i < b; i++) (r *= a) %= MOD;
  return memo[{a, b}] = r;
}

int main() {
  ll n, k;
  cin >> n >> k;

  vector<vector<ll>> d(k + 1);
  for (ll i = 1; i <= k; i++) {
    for (ll j = 1; j * j <= i; j++) {
      if (i % j == 0) {
        if (j != i) d[i].push_back(j);
        if (j != 1 && j * j != i) d[i].push_back(i / j);
      }
    }
  }

  vector<ll> t(k + 1);
  for (ll i = k; i >= 1; i--) {
    t[i] += pow(k / i, n);
    t[i] %= MOD;
    for (auto e : d[i]) {
      t[e] += MOD - t[i];
      t[e] %= MOD;
    }
  }

  ll r = 0;
  for (ll i = 1; i <= k; i++) {
    r += i * t[i];
    r %= MOD;
  }
  cout << r << endl;
}


Measured memory_bytes: 19100
#------------------------------------------------------
import numpy as np
N,D = map(int, input().split())
#複数行
xy_list = [list(map(int, input().split())) for i in range(N)]
sum=0
for xy in xy_list:
    if np.sqrt(xy[0]*xy[0]+xy[1]*xy[1])<=D:
        sum+=1
print(sum)

Measured memory_bytes: 63464
#include<iostream>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a+b==c+d)cout<<"Balanced\n";
  else if(a+b>c+d)cout<<"Left\n";
  else if(a+b<c+d)cout<<"Right\n";
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

public class Test
{
	public static void Main()
	{
		int[] N = Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
		Console.WriteLine(Math.Max((N[0]+N[1]),Math.Max((N[0]-N[1]),(N[0]*N[1]))));
	}
}


Measured memory_bytes: 13396
#include <iostream>

using namespace std;

int main(int argc, char const *argv[]){
   long long a,b,c,k;
   cin >> a >> b >> c >> k;
   if(k <= a){
      cout << k << endl;
   }  
   else if(k <= a + b){
      cout << a << endl;
   }
   else{
      cout << 2 * a + b - k  << endl;
   }
   return 0;
}

Measured memory_bytes: 3604
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int sum = 0;
    int[] A = new int[N+1];
    A[0] = 0;
    for (int i = 1; i <= N; i++) {
      A[i] = sc.nextInt();
      sum += Math.abs(A[i] - A[i-1]);
    }
    sum += Math.abs(A[N] - 0);

    for (int i = 1; i < N; i++) {
      int ans = sum
        - Math.abs(A[i] - A[i-1])
        - Math.abs(A[i+1] - A[i])
        + Math.abs(A[i+1] - A[i-1]);
      System.out.println(ans);
    }
    // i == N
    int ans = sum
      - Math.abs(A[N] - A[N-1])
      - Math.abs(A[N] - 0)
      + Math.abs(A[N-1] - 0);
    System.out.println(ans);
  }
}

Measured memory_bytes: 60040
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define null nullptr
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mp make_pair
#define test int t; cin>>t; while(t--)
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)

using namespace std;

typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;
typedef unordered_map<int,int> mp;

const int mod = 1e9+7;
const int inf = 1e17+21;

int sod(int x){
    int sum = 0;
    while(x > 0){
        sum += x%10;
        x /= 10;
    }

    return sum;
}

int32_t main(){
    FAST;

    int n;  cin >> n;
    int a,b;    cin >> a >> b;
    int ans = 0;

    for(int x=1;x<=n;x++){
        int sum = sod(x);
        if(sum >= a and sum <= b)
            ans += x;
    }

    cout << ans;


    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MOD 1000000007
#define INF 1000000000
#define LLINF 1e18

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; }

void solve_abc_a() {
	ll n, m;
	ll x, y;
	ll a, b, d;
	ll c;
	//char c;
	ll h, w;
	ll k;
	string s, t;
	//ll s, t;
	ll l_ans = 0;
	string s_ans = "NG";

	cin >> a >> b;
	if (a<=8 && b<=8){
		s_ans = "Yay!";
	}
	else{
		s_ans = ":(";
	}

	cout << s_ans << endl;

	return;
}


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed;
	cout << setprecision(7);

	solve_abc_a();

	return 0;
}


Measured memory_bytes: 3656
#include<cstring>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define ll long long
using namespace std;
int main()
{
	int s;
	int f[10]={0};
	int k,t;
	cin>>s;
	cin>>k;
	for(int i=1;i<=k;i++)
	{
		cin>>t;
		f[t]=1;
	}
	int tt;
	bool ans=1;
	for(int i=s;;i++)
	{
		t=i;
		ans=1;
		while(t)
		{
			tt=t%10;
			if(f[tt]==1)
			{
				ans=0;
				break;
			}
			t=t/10;
		}
		if(ans==1)
		{
		cout<<i<<endl;
		break;
		}
	}
}

Measured memory_bytes: 256
n = int(input())

if True:
  max_d = int(len(str(n)))
  count = 0
  if max_d % 2 == 1:
    count = n - 10**(max_d-1) + 1
    for i in range(0, max_d-2, 2):
      count += 9*10**(i)
  else:
    for i in range(0, max_d-1, 2):
      count += 9*10**(i)
  print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    int n, a, b;
    cin >> n;
    if(n == 1) {
        cout << "Hello World" << endl;
    }
    else {
        cin >> a >> b;
        cout << a + b << endl;
    }
    return 0;
}

Measured memory_bytes: 256
class UnionFindVerSize():
    def __init__(self, N):
        self._parent = [n for n in range(0, N)]
        self._size = [1] * N

    def find_root(self, x):
        if self._parent[x] == x: return x
        self._parent[x] = self.find_root(self._parent[x])
        return self._parent[x]

    def unite(self, x, y):
        gx = self.find_root(x)
        gy = self.find_root(y)
        if gx == gy: return

        if self._size[gx] < self._size[gy]:
            self._parent[gx] = gy
            self._size[gy] += self._size[gx]
        else:
            self._parent[gy] = gx
            self._size[gx] += self._size[gy]

    def get_size(self, x):
        return self._size[self.find_root(x)]

    def is_same_group(self, x, y):
        return self.find_root(x) == self.find_root(y)

    def calc_group_num(self):
        N = len(self._parent)
        ans = 0
        for i in range(N):
            if self.find_root(i) == i:
                ans += 1
        return ans

from collections import Counter

N=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
A=0
for i in range(N):
    A^=a[i]
B=0
for i in range(N):
    B^=b[i]
a.append(A)
b.append(B)

if Counter(a)!=Counter(b):
    exit(print(-1))

val=set([])
for i in range(N+1):
    if a[i]!=b[i]:
        val.add(a[i])

if not val:
    exit(print(0))

val=list(val)
val.sort()
comp={i:e for e,i in enumerate(val)}
n=max(comp[d] for d in comp)+1

uf=UnionFindVerSize(n)
check=False
cnt=0
for i in range(N):
    if a[i]!=b[i]:
        uf.unite(comp[a[i]],comp[b[i]])
        if a[i]==b[-1]:
            check=True
        cnt+=1

print(cnt+uf.calc_group_num()-int(check))


Measured memory_bytes: 142244
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define pf push_front
#define PI acos(-1)
#define EPS 1e-5
#define sz(v) ((int)(v).size())
#define all(v) v.begin(),v.end()
#define forn(i, n) for(ll i=0;i<(ll)n;i++)
#define fi first
#define se second
 

int main() {
	int n;
	cin >> n;
	vector<vector<int>> cnt(10, vector<int>(10, 0));
	for(int i = 1; i <= n; i++) {
		string s = to_string(i);
		cnt[s[0]-'0'][s[sz(s)-1]-'0']++;
	}
	ll res = 0;
	forn(i, 10) forn(j, 10)
		res += cnt[i][j] * cnt[j][i];
	cout << res << endl;
	return 0;
}



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

int main() {
  int A, N , count, count_min = 100;
  cin >> N ;
  for(int i = 0; i < N; i++){
    cin >> A; 
    count = 0;
    while(A % 2 == 0){
      A /= 2;
      count++;
    }
    count_min = min(count_min, count);
  }
  
  cout << count_min << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define pb push_back
const int N = 3005 ;
ll dp[N][N][4] ;
ll item[N][N] ;





int main(){

    ll r , c , K ;
    cin >> r >>c >> K ;
    ll i , j , k ;
    for (i = 0 ;i< K ;i++) {
        ll x , y , v ;
        cin >> x >> y >> v ;
        item[x][y] = v ;
    }

    for(i = 1 ; i<= r  ; i++) {
        for (j = 1 ;j<= c ; j++) {
                ll mx = 0 ;
            for (k = 0 ; k<= 3 ; k++) {
                mx = max ( mx , dp[i-1][j][k]) ;
            }

            for (k = 1 ; k<= 3 ; k++) {
                dp[i][j][k] = max(dp[i][j-1][k],mx+item[i][j]) ;
                dp[i][j][k] = max(dp[i][j][k],dp[i][j-1][k-1]+item[i][j]) ;
            }
        }
    }
    ll ans = 0 ;
    for (i = 0;  i<= 3 ; i++)
        ans = max({dp[r][c][i],ans}) ;
    cout << ans ;
    return 0 ;
}


Measured memory_bytes: 355308
def abc155_b():
    N = int(input())
    A = list(map(int, input().split()))
    result = 'APPROVED'

    evens = [i for i in A if i % 2 == 0]
    for i in evens:
        if (i % 3 != 0) and (i % 5 != 0):
            result = 'DENIED'

    print(result)


##########
if __name__ == "__main__":
    abc155_b()


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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#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 ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

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

  SCIN(s, t);
  sort(ALL(s));
  sort(ALL(t));
  reverse(ALL(t));

  OK(s < t);

  return 0;
}



Measured memory_bytes: 256
S = input()

K = S.count("R")

if K == 0:
    print(0)

elif K == 1:
    print(1)

elif K == 3:
    print(3)

elif K == 2:
    k2 = S.count("RR")
    if k2 == 0:
        print(1)
    else:
        print(2)


Measured memory_bytes: 9060
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

sys.setrecursionlimit(10 ** 7)

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

import math

n, h = na()
a = []
b = []
for i in range(n):
    _a, _b = na()
    a.append(_a)
    b.append(_b)

a.sort(reverse=True)
b.sort(reverse=True)

i = 0
cnt = 0
while h > 0:
    if i < n and a[0] < b[i]:
        h -= b[i]
        i += 1
        cnt += 1
    else:
        cnt += math.ceil(h / a[0])
        break

print(cnt)

Measured memory_bytes: 11436
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

//約数列挙（因数分解）
vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int digit(ll n) {
	int res = 0;
	while (n) {
		n /= 10;
		res++;
	}
	return res;
}

int main() {
	ll n;
	cin >> n;
	auto v = divisor(n);
	int ans = 1001001001;
	for(ll t: v) {
		int now = max(digit(t), digit(n/t));
		ans = min(ans, now);
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  multiset<int> ms;
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    ms.insert(x);
  }
  while (m--) {
    int top = *ms.rbegin();
    ms.erase(prev(ms.end()));
    top /= 2;
    ms.insert(top);
  }
  long long ans = 0;
  for (int x : ms)
    ans += x;
  printf("%lld\n", ans);
  return 0;
}

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

int main(){
	int n, m, i, j, t, k;
	while(~scanf("%d %d", &n, &m)){
		char a[111][111];
		getchar();
		for(i = 0; i < n; i++)  { gets(a[i]); a[i][m] = '#'; }
		for(i = 0; i < m + 2; i++)  printf("#");
		printf("\n");
		for(i = 0; i < n; i++){
			printf("#");
			for(j = 0; j <= m; j++)
				printf("%c", a[i][j]);
			printf("\n");
		}
	    for(i = 0; i < m + 2; i++)  printf("#");
	    printf("\n");
	}
	return 0;
}

Measured memory_bytes: 128
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx2,tune=native")
//#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("trapv")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using pi = pair<ll, ll>;
const ll mod = 7 * 17 * (1 << 23) + 1;
const ll inf = 1e18;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n, C = 0, col[300300];
vector<vector<pair<int, int>>> g;
void dfs(int v, int p = 0, int c = 0) {
	c = (c+1)%C;
	for(auto i : g[v]) {
		if(i.first==p) continue;
		col[i.second]=c;
		dfs(i.first, v, c);
		c = (c+1)%C;
	}
}
int main() { //DINIC ORZ
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	g.resize(n+1);
	for(int f, t, i = 1; i < n; i++) {
		cin >> f >> t;
		g[f].pb({t, i});
		g[t].pb({f, i});
		C = max(C, (int)g[f].size());
		C = max(C, (int)g[t].size());
	};
	dfs(1, 0);
	cout << C << "\n";
	for(int i = 1; i < n; i++) cout << 1+col[i] << "\n";
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.rbegin(); itr != x.rend(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

using llong = long long int;

const static llong MOD = 1000000007;
const static int IINF = INT_MAX;
const static llong LINF = LLONG_MAX;
const static int dx[4] = {1, 0, -1, 0};
const static int dy[4] = {0, 1, 0, -1};

template<typename T> T my_gcd(T a, T b) {
    return (a ? my_gcd(b % a, a) : b);
}
template<typename T> T my_lcm(T a, T b) {
    return a * b / my_gcd(a, b);    
}
llong powmod(llong a, llong n) {
    llong res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }

    return res;
}
llong facmod(llong n) {
    if (n == 0) return 1;
    llong res = n;
    for (int i = n - 1; i > 0; --i) {
        res = (res * i) % MOD;
    }

    return res;
}
llong combmod(llong n, llong k) {
    llong res = 1;
    for (int i = 0; i < k; ++i) {
        res = (res * (n - i)) % MOD;
    } 
    res = (res * powmod(facmod(k), MOD - 2)) % MOD;

    return res;
}

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    llong n, a, b;
    cin >> n >> a >> b;
    if (n == 2) {
        cout << 0 << endl;
        return 0;
    }

    llong ans = powmod(2, n) - 1;
    ans = (ans - combmod(n, a)) % MOD;
    if (ans < 0) ans += MOD;
    ans = (ans - combmod(n, b)) % MOD;
    if (ans <  0) ans += MOD;

    cout << ans << endl;

    return 0;
}

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

using namespace std;
using ll = long long;
constexpr int INF = 1 << 29;

int main() {
    int n,k,x,y;
    cin >> n >> k >> x >> y;
    cout << ((n>k) ? k*x+(n-k)*y : n*x) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll k; cin >> k;
    string s; cin >> s;

    if(s.size() <= k){
        cout << s << endl;
    }
    else{
        rep(i, k){
            cout << s[i];
        }
        cout << "..." << endl;
    }

    return 0;
}

Measured memory_bytes: 3592
/**
	Language: C++
	Author  : 21
**/

#include <bits/stdc++.h>

using namespace std;

#define FastIO() ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
#define Debug(v) cerr << '\n' << #v << ":\t" << v << '\n'

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;

int main() {
	FastIO();
	int n, k;
	cin >> n >> k;
	vector<bool> s(n, false);
	int d, a;
	for (int i = 0; i < k; ++i) {
		cin >> d;
		while (d--) {
			cin >> a;
			s[a-1] = true;
		}
	}
	int ans = count(s.begin(), s.end(), false);
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3660