akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3


S, stack = [], []
N = 0


def main() -> None:
    global N
    N, A, B, C = rmi()
    for n in range(N):
        S.append(r())
    enable = dfs(stack, 0, A, B, C)
    w('Yes' if enable else 'No')
    if enable:
        wm(*stack, delim='\n')


def dfs(stack, index, a, b, c) -> bool:
    if N <= index:
        return True
    inst = S[index]
    if inst == 'AB':
        if a <= 0 and b <= 0:
            return False
        if 0 < a:
            stack.append('B')
            result = dfs(stack, index + 1, a - 1, b + 1, c)
            if result:
                return True
            else:
                stack.pop()
        if 0 < b:
            stack.append('A')
            result = dfs(stack, index + 1, a + 1, b - 1, c)
            if result:
                return True
            else:
                stack.pop()
    elif inst == 'AC':
        if a <= 0 and c <= 0:
            return False
        if 0 < a:
            stack.append('C')
            result = dfs(stack, index + 1, a - 1, b, c + 1)
            if result:
                return True
            else:
                stack.pop()
        if 0 < c:
            stack.append('A')
            result = dfs(stack, index + 1, a + 1, b, c - 1)
            if result:
                return True
            else:
                stack.pop()
    else:
        if b <= 0 and c <= 0:
            return False
        if 0 < b:
            stack.append('C')
            result = dfs(stack, index + 1, a, b - 1, c + 1)
            if result:
                return True
            else:
                stack.pop()
        if 0 < c:
            stack.append('B')
            result = dfs(stack, index + 1, a, b + 1, c - 1)
            if result:
                return True
            else:
                stack.pop()
    return False


def r() -> str:
    return input().strip()


def ri() -> int:
    return int(r())


def rmi(delim: str = ' ') -> tuple:
    return tuple(map(int, input().split(delim)))


def w(data) -> None:
    print(data)


def wm(*data, delim: str = ' ') -> None:
    print(delim.join(map(str, data)))


if __name__ == '__main__':
    import sys
    sys.setrecursionlimit(10**9)
    main()


Measured memory_bytes: 110748
# H時M分が与えられて長針と短針のなす角Θ(0度<=Θ<180度)を返す

# 度数法 (0度<=Θ<180度)
def dos(H,M):
    H%=12
    return min(abs(30*H-5.5*M),360-abs(30*H-5.5*M))

# 弧度法　(0<=Θ<π)
import math 
def radi(H,M):
    H%=12
    return math.pi*min(abs(30*H-5.5*M),360-abs(30*H-5.5*M))/180

from math import cos,sqrt
a,b,h,m=map(int,input().split())
print(sqrt(a**2+b**2-2*a*b*cos(radi(h,m))))

Measured memory_bytes: 62568
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

vector<int> as;
vector<ll> ss;

ll solve(const int N, const int M) {
    map<int, ll> m;

    ll ans = 0;

    for (int i = 0; i <= N; i++) {
        int x = ss[i] % M;
        ans += m[x];
        m[x]++;
    }

    return ans;
}

int main(void) {
    int N, M;
    cin >> N >> M;

    as.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> as[i];
    }

    ss.resize(N + 1, 0);
    for (int i = 0; i < N; i++) {
        ss[i + 1] = ss[i] + as[i];
    }

    cout << solve(N, M) << endl;

    return 0;
}


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

double x1, y1, x2, y2, x3, y3, xp, yp;

int side(double p1_x, double p1_y, double p2_x, double p2_y){
	double n = xp*(p1_y - p2_y) + p1_x*(p2_y - yp) + p2_x*(yp - p1_y);
	if(n > 0) return 1; // left
	else if(n < 0) return -1; //right
	else return 0; //on_line
}

bool judge_in(){
	int pab = side(x1,y1,x2,y2);
	int pbc = side(x2,y2,x3,y3);
	int pca = side(x3,y3,x1,y1);

	if((pab > 0) && (pbc > 0) && (pca > 0)) return true;
	if((pab < 0) && (pbc < 0) && (pca < 0)) return true;
	return false;
}


int main(){
	while(cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp){
		bool judge = judge_in();
		if(judge == true) cout << "YES" << endl;
		else if(judge == false) cout << "NO" << endl;
	}
}

Measured memory_bytes: 1216
// https://atcoder.jp/contests/abc175/tasks/abc175_e

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
using ll = long long;
using ld = long double;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
template <typename T>
using VV = V<V<T>>;
using VVL = VV<ll>;
template <typename T>
using VVV = VV<V<T>>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
using asc_pq = priority_queue<T, V<T>, greater<T>>;

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline ll len(V<T> arr) {
  return arr.size();
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

ll dp[3000][3000][4];
ll val_mat[3000][3000];

void solve() {
  ll R, C, K;
  cin >> R >> C >> K;

  rep(i, K) {
    ll r, c, v;
    cin >> r >> c >> v;
    --r, --c;
    val_mat[r][c] = v;
  }

  rep(r, R) rep(c, C) rep(used, 4) rep(dir, 2) {
    ll nr = dir ? r + 1 : r;
    ll nc = dir ? c : c + 1;

    unless(nr < R && nc < C) continue;

    chmax(dp[nr][nc][r != nr ? 0 : used], dp[r][c][used]);

    if (used < 3) {
      chmax(dp[nr][nc][r != nr ? 0 : used + 1], dp[r][c][used] + val_mat[r][c]);
    }
  }

  ll res = 0;
  rep(i, 4)
      chmax(res, dp[R - 1][C - 1][i] + (i < 3 ? val_mat[R - 1][C - 1] : 0));

  cout << res << "\n";
}


Measured memory_bytes: 355148
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < (n); ++(i))
#define repeat_from(i, m, n) for (int i = (m); (i) < (n); ++(i))
using namespace std;
template <class T>
void setmax(T &a, T const &b) {
    if (a < b) a = b;
}

template <class T>
void setmin(T &a, T const &b) {
    if (a > b) a = b;
}

template <typename T, typename X>
auto vectors(T a, X x) { return vector<T>(x, a); }

template <typename T, typename X, typename Y, typename... Zs>
auto vectors(T a, X x, Y y, Zs... zs) {
    auto cont = vectors(a, y, zs...);
    return vector<decltype(cont)>(x, cont);
}

const long long mod = 1000000007;

int main() {
    int N;
    cin >> N;
    vector<long long> dp(N + 1, 0);
    dp[0] = 1;
    long long res = 0;
    for (int End = N - 2; End > 0; End -= 3) {
        for (int i = 1; i < End; ++i) {
            dp[i] = (dp[i] + dp[i - 1]) % mod;
        }
        res = (res + dp[End - 1]) % mod;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3628
import sys
sys.setrecursionlimit(10000000)
def calc(dp,adj,i):
    if(len(adj[i])==0):
        dp[i]=0
    elif dp[i]>0:
        return dp[i]
    else:
        for j in adj[i]:
            dp[i]=max(dp[i],calc(dp,adj,j))
        dp[i]+=1
    return dp[i]
n,m=map(int,input().split())
adj=[]
for i in range(n+1):
    adj.append([])
for i in range (m):
    x,y=map(int,input().split())
    adj[x].append(y)
dp=[-1]*(n+1);
for i in range(1,n+1):
    calc(dp,adj,i)
print(max(dp))


Measured memory_bytes: 59056
#include <iostream>
#include <string>
using namespace std;
int main(void){
    long long n;
    int tmp = 0;
    cin >> n;
    string s = to_string(n),z;
    z = s[0];
    for(int i = 0;i < s.length();i++){
        if(i != 0){
            if(s[i] == '9') tmp++;
        }
    }
    int x = atoi(z.c_str());
    if(tmp == s.length()-1)cout << x+9*(s.length()-1) << endl;
    else cout << x+9*(s.length()-1)-1 << endl;
}

Measured memory_bytes: 256
from itertools import permutations
N = int(input())
A = tuple(map(int, input().split()))

*PS, = permutations(range(1, N+1), r=N)
i = PS.index(A)
if i > 0:
    print(*PS[i-1])
print(*A)
if i < len(PS)-1:
    print(*PS[i+1])


Measured memory_bytes: 52360
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,r,p=0;
    cin>>n;
    while(n!=0)
    {
        r=n%10;
        n=n/10;
        if(r==7)
        {
            p=1;
            break;
        }
    }
    if(p==1)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


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

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;
const long long MOD = (long long)1e9 + 7;

int main(){
    int x;
    cin >> x;
    for(int a = -118; a <= 119; a++){
        for(int b = -119; b <= 118; b++){
            ll y = a * a * a * a * a - b * b * b * b * b;
            if(x == y){
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3624
#include <cstdio>
#include <cstring>

const int MaxN = 3000, MaxM = 3000;
const int Mod = 998244353;

int N, M, Ans;
int A[MaxN + 5];
int F[MaxM + 5], Buc[MaxM + 5];

inline int add(int x, int y) { return (x += y) >= Mod ? x - Mod : x; }
inline int sub(int x, int y) { return (x -= y) < 0 ? x + Mod : x; }
inline int mul(int x, int y) { return 1LL * x * y % Mod; }
inline void inc(int &x, int y = 1) { x = add(x, y); }

void init() {
  scanf("%d %d", &N, &M);
  for (int i = 1; i <= N; ++i) scanf("%d", &A[i]);
}

void fun(int l, int r) {
  if (l == r) {
    if (A[l] == M) inc(Ans);
    return;
  }
  int m = (l + r) >> 1;
  fun(l, m);
  fun(m + 1, r);
  memset(Buc, 0, sizeof Buc);
  memset(F, 0, sizeof F);
  F[0] = 1;
  for (int i = m; i >= l; --i) {
    for (int j = M; j >= A[i]; --j) inc(F[j], F[j - A[i]]);
    for (int j = 0; j <= M; ++j) inc(Buc[j], F[j]);
  }
  memset(F, 0, sizeof F);
  F[0] = 1;
  for (int i = m + 1; i <= r; ++i) {
    for (int j = M; j >= A[i]; --j) inc(F[j], F[j - A[i]]);
    for (int j = 0; j <= M; ++j) inc(Ans, mul(F[j], Buc[M - j]));
  }
}

void solve() {
  fun(1, N);
  printf("%d\n", Ans);
}

int main() {
  init();
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <string>
#include <vector>
#include <numeric> /* gcd, lcm, partial_sum, reduce*/
#include <iostream>
#include <algorithm>

using namespace std;
using ll = long long; // c++11

long long solve(long long n){
  if(n<5) return 0LL;
  if(n%2==1)return 0LL;

  // n, n-2, n-4, ... , 2
  ll ans = 0LL;
  // vector<ll> fives;
  // fives[0]=5LL;
  // for(int i=0; fives[i]<=n; i++){
  //   fives[i+1] = fives[i]*5LL; // 5, 25, 125, 525, ...
  // }
  ll five = 5LL;
  while(five*2LL <= n){
    ans += n/(five*2LL);
    five *= 5LL;
  }
  return ans;
}

int main(){
  ll n;
  cin >> n;
  cout << solve(n) << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
P =[]
s = 0
for _ in range(n):P.append(list(map(int,input().split())))
P.append(P[0])
for j in range(n):s += P[j][0]*P[j+1][1] - P[j][1]*P[j+1][0]
print(s*0.5)

Measured memory_bytes: 7668
#include<stdio.h>
int main()
{
	long int n,t,num;
	long int sum=0;
	scanf("%ld",&num);
	n=num;
	while(n)
	{
		t=n%10;
		sum=sum+t;
		n=n/10;
	}
	if(num%sum==0)
	printf("Yes");
	else
	printf("No");
	return 0;
}


Measured memory_bytes: 128
#include <map>
#include <vector>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

long long ret;
map<pair<string, string>, int> cnt;

void solve()
{
    int n;
    ret = 0;
    string s;
    cin >> n >> s;
    for (int mask = 0; mask < (1 << n); mask++) {
        string a, b;
        for (int i = 0; i < n; i++) {
            if (mask >> i & 1) a += s[i];
            else b += s[i];
        }
        cnt[make_pair(a, b)]++;
    }
    for (int mask = 0; mask < (1 << n); mask++) {
        string a, b;
        for (int i = 0; i < n; i++) {
            if (mask >> i & 1) a += s[n + n - 1 - i];
            else b += s[n + n - 1 - i];
        }
        ret += cnt[make_pair(a, b)];
    }
    cout << ret << endl;
}

int main()
{
    solve();
    return 0;
}



Measured memory_bytes: 91904
import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    n, k = input_int_list()
    X = input_int_list()
    ans = float("inf")
    for i in range(0, n - k + 1):
        tmp_min = X[i]
        tmp_max = X[i + k - 1]
        if tmp_max <= 0:
            tmp = abs(tmp_min)
        elif tmp_min >= 0:
            tmp = abs(tmp_max)
        else:
            tmp = min(abs(tmp_max), abs(tmp_min)) * 2 + max(abs(tmp_max), abs(tmp_min))
        ans = min(tmp, ans)
    print(ans)
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 85580
#include<iostream>
using namespace std;
int main(void)
{
	int n,x;
	cin>>n>>x;
	while(n!=0||x!=0){
		int i,j,k;
		int o=0;
		for(i=1;i<=n;i++){
			for(j=i+1;j<=n;j++){
				for(k=j+1;k<=n;k++){
					if(i+j+k==x) o++;
				}
			}
		}
		cout<<o<<endl;
		cin>>n>>x;
	}
	return 0;
}


Measured memory_bytes: 2988
N = int(input())
D = [list(map(int, input().split())) for i in range(N)]
time = 0
for i in range(N):
    if D[i][0] == D[i][1]:
        time += 1
        if time == 3:
            print('Yes')
            exit()
    else:
        time = 0
print('No')

Measured memory_bytes: 9112
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
int n, W;
const int MAXN = 100000;
int dp[MAXN + 10];
int main()
{
	cin >> n >> W;
	memset(dp, INF, sizeof(dp));
    dp[0] = 0;
	for (int i = 1; i <= n; i++) {
		int v, w;
		cin >> w >> v;
		for (int j = MAXN; j >= v; j--)dp[j] = min(dp[j], dp[j - v] + w); 
	}
	int ans = INF;
	for (int i = 0; i <= MAXN; i++)if (dp[i] <= W)ans = i;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sstream>
#include <iostream>
#include <math.h>
#include <time.h>
#include <unistd.h>
#include <algorithm>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <string>

#ifndef ONLINE_JUDGE
	#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#else
	#define DEBUG(x) do {} while(0);
#endif

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define FOR(i, A, N) for(int (i) = (A); (i) < (N); (i)++)
#define REP(i, N) for(int (i) = 0; (i) < (N); (i)++)

using namespace std;
typedef long long ll;
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }

int n,m;
int A[1111][1111];
int K[1111][1111];

using vi = vector<int>;
int stages[1111111];
vi topo_sort(const vector<vi>& gr) {
	vi indeg(gr.size()), ret;
	for(auto li : gr) for(auto x : li) indeg[x]++;
	queue<int> q; // use priority queue for lexic. smallest ans.
	REP(i, gr.size()) if (indeg[i] == 0) {
		stages[i] = 1;
		q.push(-i);
	}
	while (!q.empty()) {
		int i = -q.front(); // top() for priority queue
		ret.push_back(i);
		q.pop();
		for(auto x : gr[i])
			if (--indeg[x] == 0) {
				q.push(-x);
				stages[x] = stages[i]+1;
			}
	}
	return ret;
}

int main() {
	m = 0;
	scanf("%d", &n);
	vector<vi> graph;
	REP(i, n) {
		vector<int> matches;
		REP(j, n-1) {
			int a = i, b;
			scanf("%d", &b);
			b--;
			if(a < b) {
				K[a][b] = m;
				matches.pb(m);
				m++;
				if(graph.size() < m) {
					graph.pb({});
				}
			} else {
				matches.pb(K[b][a]);
			}
		}
		REP(j, (int)matches.size()-1) {
			graph[matches[j]].pb(matches[j+1]);
		}
	}
	auto topo = topo_sort(graph);
	if(topo.size() != graph.size()) {
		printf("-1\n");
		return 0;
	}
	int ans = 0;
	REP(i, graph.size()) ans = max(ans, stages[i]);
	printf("%d\n", ans);
	return 0;
}


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

int main(){
    int n;
    cin >> n;

    string s;
    cin >> s;

    int cou = 0;
    int right = 0;
    int left = 0;
    int ans = 0;

    for(int i = 1; i < n; i++){
        cou = 0;
        for(char c = 'a'; c <= 'z'; c++){
            right = 0;
            left = 0;
            for(int j = 0; j < i; j++){
                if(s[j] == c){
                    left = 1;
                }
            }
            for(int j = i; j < n; j++){
                if(s[j] == c){
                    right = 1;
                }
            }

            if(left == 1 && right == 1){
                cou++;
            }
        }
        if(ans <= cou){
            ans = cou;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin>>n;
    
    bool b=true;
    
    vector<string> str;
    string temp;
    cin>>temp;
    str.push_back(temp);
    
    for(int i=1; i<n; i++){
        cin>>temp;
        
        if(temp[0]!=str[i-1][str[i-1].size()-1]){
            b=false;
        }
        
        for(int j=0; j<i; j++){
            if(temp==str[j]){
                b=false;
            }
        }
        
        str.push_back(temp);
        
        if(!b){
            break;
        }
    }
    
    if(b){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
import itertools

N=int(input())

ans=[0 for i in range(11000)]
T=[i+1 for i in range(110)]
CMB=list(itertools.combinations_with_replacement(T,3))

def f(l):
    x,y,z=l[0],l[1],l[2]
    return x*x+y*y+z*z+x*y+y*z+z*x


for i in range(len(CMB)):
    cmb=CMB[i]
    J=len(set(cmb))
    F=f(cmb)
    if F<11000:
        if J==1:
            ans[F]+=1
        elif J==2:
            ans[F]+=3
        else:
            ans[F]+=6

for i in range(1,N+1):
    print(ans[i])

Measured memory_bytes: 25396
#include<bits/stdc++.h>
#define ll long long
using namespace std;
bool cmp(ll a,ll b)
{
    return a>b;
}
int main()
{
    int n,m;
    priority_queue<ll>q;
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++)
    {
        ll a;
        scanf("%lld",&a);
        q.push(a);
    }
    for(int i=1;i<=m;i++)
    {
        int a=q.top()/2;
        q.pop();
        q.push(a);
    }
    ll u=0;
    for(int i=0;i<n;i++)
    {
        u=u+q.top();
        q.pop();
    }
    printf("%lld\n",u);
    return 0;
}


Measured memory_bytes: 1400
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		//差込口
		int insertPlag = 1;

		int count = 0;

		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		int B = sc.nextInt();

		while(B > insertPlag) {
			insertPlag += A - 1;
			count++;
		}

		System.out.println(count);
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

const int WHITE = 0;
const int BLACK = 1;

void main_()
{
    ll N;
    cin >> N;
    string S;
    cin >> S;

    array<ll, 2> dp;

    if (S[0] == '#') {
        dp[WHITE] = 1;
        dp[BLACK] = 0;
    } else {
        dp[WHITE] = 0;
        dp[BLACK] = 1;
    }

    for (ll i = 1; i < N; ++i) {
        array<ll, 2> dp_n;
        // 白にする場合
        if (S[i] == '#') {
            // 黒→白
            dp_n[WHITE] = dp[WHITE] + 1;
        } else {
            // 白→白
            dp_n[WHITE] = dp[WHITE];
        }

        // 黒にする場合
        if (S[i] == '#') {
            // 黒→黒
            dp_n[BLACK] = min(dp[WHITE], dp[BLACK]);
        } else {
            // 白→黒
            dp_n[BLACK] = min(dp[WHITE], dp[BLACK]) + 1;
        }
        dp = dp_n;
    }

    ll ans = min(dp[WHITE], dp[BLACK]);
    cout << ans << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


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

using namespace std;

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi vector<int>
#define vvi vector<vector<int> >
#define vpi vector<pi >
#define pi pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define all(n) n.begin(), n.end()

#define FROMTO(var, from, to) for (register int var = (from), var##down = ((int)(to)) < ((int)(from));var##down ? (var >= (int)(to)) : (var <= (int)(to));var##down ? var-- : var++)
#define UPTO(var, from, to)   for (register int var = (from); var <= ((int)to); var++)
#define DOWNTO(var, from, to) for (register int var = (from); var >= ((int)to); var--)
#define FOR(var, to)          UPTO(var, 0, (to)-1)
#define DOWN(var, from)       DOWNTO(var, (from)-1, 0) 

#define INIT(var, val) FOR(i,countof(var)) var[i] = val
#define INPUT(var) FOR(i,countof(var)) cin >> var[i]
#define INPUT1(var) FOR(i,countof(var)) cin >> var[i], var[i]--

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)
#define QSORT(v,b) qsort(v,countof(v),sizeof(*v),b)

#define MOD 1000000007
#define INF ((1 << 30)-1)
#define LINF ((1LL << 62)-1)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

struct Comb {
    vector<vector<s64> > data;
    Comb(int n) { // O(n^2)
        data = vector<vector<s64> >(n+1,vector<s64>(n+1,1));
        UPTO(i,1,n) {
            FOR(j,i+1) {
                if (!j || j == i) data[i][j] = 1;
                else data[i][j] = data[i-1][j-1] + data[i-1][j];
            }
        }
    }
    
    s64 ncr(int n, int r) {
        return data[n][r];
    }
};

static inline int ri() {
  int a;
  scanf("%d", &a);
  return a;
}

int int_less(const void *a, const void *b) {
  return (*((const int*)a) - *((const int*)b));
}
int int_greater(const void *a, const void *b) {
  return (*((const int*)b) - *((const int*)a));
}
int main() {
	int n = ri();
	int g = ri();
	g /= 100;
	int a[n];
	int b[n];
	FOR(i,n) a[i] = ri(), b[i] = ri();
	
	vi dp(g+1);
	FOR(i,g+1) dp[i] = INF;
	dp[0] = 0;
	FOR(i,n) {
		vi dp_new = dp;
		FOR(j,a[i]+1) {
			if (!j) continue;
			FOR(k,g) {
				if (dp[k] == INF) continue;
				int plus = j*(i+1);
				if (j == a[i]) plus += b[i]/100;
				dp_new[min(g,k+plus)] = min(dp_new[min(g,k+plus)], dp[k] + j);
			}
		}
		dp = dp_new;
	}
	cout << dp[g] << endl;
    return 0;
}


Measured memory_bytes: 1120
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

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

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input!(k: usize, s: chars);
    let mut s = s;
    if s.len() > k {
        while s.len() > k {
            s.pop();
        }
        for _ in 0..3 {
            s.push('.');
        }
    }
    for c in s {
        puts!("{}", c);
    }
    puts!("\n");
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 2280
// A.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

int main(int argc, char* argv[]) {
	int a, b;
	cin >> a >> b;
	int ans = 0;
	if (a == 1) {
		ans += 300000;
	}
	if (a == 2) {
		ans += 200000;
	}
	if (a == 3) {
		ans += 100000;
	}
	if (b == 1) {
		ans += 300000;
	}
	if (b == 2) {
		ans += 200000;
	}
	if (b == 3) {
		ans += 100000;
	}
	if (a == 1 && b == 1) {
		ans += 400000;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    int64_t r,D,x;
    cin >> r >> D >> x;
    for(int i=0; i<10; i++)
    {
        cout << r*x-D << endl;
        x=r*x-D;
    }
}


Measured memory_bytes: 3576
import sys
from io import StringIO
import unittest
import os
import collections

# 再帰処理上限(dfs作成時に設定するのが面倒なので限度近い値を組み込む)
sys.setrecursionlimit(999999999)


# 実装を行う関数
def resolve(test_def_name=""):
    # 数値取得サンプル
    #   1行1項目 n = int(input())
    #   1行2項目 x, y = map(int, input().split())
    #   1行N項目 x = [list(map(int, input().split()))]
    #   N行1項目 x = [int(input()) for i in range(n)]
    #   N行N項目 x = [list(map(int, input().split())) for i in range(n)]

    # 文字取得サンプル
    #   1行1項目 x = input()
    #   1行1項目(1文字ずつリストに入れる場合) x = list(input())
    n = int(input())
    a_s = list(map(int, input().split()))

    q = int(input())
    query_s = [list(map(int, input().split())) for i in range(q)]

    # counter = list(collections.Counter(a_s))
    counter = [0 for i in range(100001)]

    for i in a_s:
        counter[i] += 1

    sum_val = sum(a_s)
    for query in query_s:
        sum_val += (query[1] * counter[query[0]]) - (query[0] * counter[query[0]])
        counter[query[1]] += counter[query[0]]
        counter[query[0]] = 0
        print(sum_val)


# テストクラス
class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve(sys._getframe().f_back.f_code.co_name)
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """4
1 2 3 4
3
1 2
3 4
2 4"""
        output = """11
12
16"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """4
1 1 1 1
3
1 2
2 1
3 5"""
        output = """8
4
4"""
        self.assertIO(test_input, output)

    def test_input_3(self):
        test_input = """2
1 2
3
1 100
2 100
100 1000"""
        output = """102
200
2000"""
        self.assertIO(test_input, output)

    # 自作テストパターンのひな形(利用時は「tes_t」のアンダーバーを削除すること
    def tes_t_1original_1(self):
        test_input = """データ"""
        output = """データ"""
        self.assertIO(test_input, output)


# 実装orテストの呼び出し
if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        # AtCoder提出時の場合
        resolve()

    else:
        # 自PCの場合
        unittest.main()


Measured memory_bytes: 102300
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;


public class Main {
	static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
	public static void main (String[] args) {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		double d = sc.nextInt();
		
		int[] x = new int[n];
			int[] y = new int[n];
		int count=0;
		for(int i=0;i<n;i++){
			x[i]=sc.nextInt();
				y[i]=sc.nextInt();
				double dis = Math.sqrt(Math.pow(x[i],2)+Math.pow(y[i],2));
				if(dis<=d) count++;
		}
		System.out.println(count);
    }
}


Measured memory_bytes: 57524
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<math.h>
typedef long long ll;
using namespace std;
 
int main()
{
	int A, B; scanf("%d%d", &A, &B);
	if (1 > A || A > 9 || 1 > B || B > 9) printf("-1");
	else printf("%d", A*B);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdlib>
#include<string>
#include<stdlib.h>
using namespace std;

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

int h,w;
string s[50];

void solve(int x,int y){
    if(s[y][x]=='.'){
        int cnt=0;
        for(int i=0;i<8;i++){
            int nx=x+dx[i];
            int ny=y+dy[i];
            if(0<=nx&&nx<w&&0<=ny&&ny<h){
                if(s[ny][nx]=='#')cnt++;
            }
        }
        cout<<cnt;
    }
    else cout<<"#";
}

int main()
{
    cin>>h>>w;
    for(int i=0;i<h;i++){
        cin>>s[i];
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            solve(j,i);        
        }
        cout<<endl;
    }
    
    return 0;
}


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

a=True
for i in range(N):
    if A[i]%2==0:
        if A[i]%3!=0 and A[i]%5!=0:
            print("DENIED")
            a=False
            break
if a==True:
    print("APPROVED")

Measured memory_bytes: 38384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in); 
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		int d = a / b;
		int r = a % b;
		double f = (double)a / b;

		System.out.println(d + " " + r + " " + String.format("%.5f", f));
	}
}

Measured memory_bytes: 17176
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
using ll = long long;

int main() {
    string S;
    cin >> S;

    bool flug = true;
    // 奇数
    for (int i = 0; i < S.size(); i += 2) {
        if (S[i] == 'R' || S[i] == 'U' || S[i] == 'D') {
        } else {
            flug = false;
        }
    }
    
    // 偶数
    for (int i = 1; i < S.size(); i += 2) {
        if (S[i] == 'L'  || S[i] == 'U' || S[i] == 'D') {
        } else {
            flug = false;
        }
    }

    if (flug) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}




Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.*;
	
	public class Main {
	
		public static void main(String[] args) {
		
			Scanner sc = new Scanner(System.in);
			int n = sc.nextInt();
			int k = sc.nextInt();
			Integer[] h = new Integer[n];
			long sum = 0;
			
			
			for(int i=0;i<n;i++) {
				h[i]=sc.nextInt();
			}
			
			Arrays.sort(h,Collections.reverseOrder());
			
			if(n<=k) {
				System.out.println(0);
				return;
			}else {
				for(int i=k;i<n;i++) {
					sum += h[i];
				}
				
				System.out.println(sum);
			}
			
			
			
			
			
		}
				
	}

Measured memory_bytes: 93268
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define INF 0x3f3f3f3f

using namespace std;

typedef vector<int> vi;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pi;

void solve(){
    int v[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    int n; cin >> n;
    cout << v[n-1] << endl;
}

int main(){
    //int t; cin >> t;
    //while(t--) solve();

    solve();
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args)
  {
    
    Scanner input = new Scanner(System.in);
    int n = input.nextInt();
    int[] a = new int[n];
    for(int i=0;i<n;i++)
        a[i] = input.nextInt();
        
    int g=0,h=1,i=0;
    boolean flag = false;
    while(i<n)
    {
        if(a[i]==h)
        {
            flag = true;
            h++;
            g++;
        }
        i++;
    }
    if(!flag)
        System.out.println(-1);
    else
        System.out.println(n-g);
  }
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  // Including tree_order_statistics_node_update

using namespace __gnu_pbds;
using namespace std;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
#define minei(x) min_element(x.begin(), x.end()) - (x).begin()
#define maxei(x) max_element(x.begin(), x.end()) - (x).begin()
#define LSOne(S) (S & (-S))

#define uns(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define acusum(x) accumulate(x.begin(), x.end(), 0)
#define acumul(x) accumulate(x.begin(), x.end(), 1, multiplies<int>());
#define bits(x) __builtin_popcount(x)
#define oo INT_MAX
#define inf 1000000000
#define MAXN 1000007
#define MOD 1000000007

const double pi = acos(-1.0);
const double eps = 1e-11;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

int main() {
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int k;
    string s;
    cin >> k >> s;
    if (sz(s) <= k)
        cout << s << endl;
    else
        cout << s.substr(0, k) + "..." << endl;

    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define repr(i, n, m) for (int i = (int)(n) - 1; i >= (int)(m); i--)
using namespace std;
using ll = int64_t;
const int MOD = 1000000007; // 10^9+7

int main() {
    double n, m, d;
    cin >> n >> m >> d;

    double ans;
    if (d == 0) {
        ans = (m - 1) / n;
    } else {
        ans = 2 * (n - d) * (m - 1) / (n * n);
    }
    cout << fixed << setprecision(10) << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll x;
    cin >> x;

    out(1000*(x/500) + 5*((x%500)/5));
    
    re0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdio.h>
#include<bits/stdc++.h>
#include<vector>
#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
using namespace std;
void a1(){
    int i, len = 3;
    char str[] = "abc";
    for(i=0;i<len;i++){
        printf("%c\n",str[2-i]);
    }
    return;
}

int length(char str[5]){
    int cut=0;
    while(*(str+cut)!='\0'){
        cut++;
    }
    return cut;
}

void a2(){
    char a[4][5]={"ab","cdef","g","hij"};
    int i;
    for(i=0; i<4; i++){
        printf("%d\n",length(a[i]));
    }
    return;
}

void a3(){
    char str[4];
    strcpy(str,"abc");
    printf("%s\n",str);
    return;
}

void a4(){
    char a[7]="saitou",b[7] = "suzuki";
    int i;

    for(i=0;i<7;i++){
        int k = a[i]-b[i];
        if(k > 0){
            printf("%c",a[i]);
        }else if(k < 0){
            printf("%c",b[i]);
        }else{
            printf("0");
        }
    }
    printf("\n");
    return;
}

void a5(){
    char *a[3];
    int n,i,j,cut = 0;
    for(i=0;i<3;i++){
        scanf("%d",&n);
        a[i]=(char *)malloc((n+1)*sizeof(char));
        scanf("%s",a[i]);
    }
    for(i=0;i<3;i++){
        for(j=0;j<strlen(a[i]);j++){
            if(a[i][j]=='P'||a[i][j]=='p'){
                cut++;
            }
        }
    }
    printf(">> %d\n",cut);
    for(i=0;i<3;i++){
        free(a[i]);
    }
}

void y(){
    int n,m;
    vector<int> v,v2;
    while(1){
    cin >> n >> m;
    v.clear();v2.clear();
    if(n==0&&m==0)break;
    v.push_back(0);
    rep(i,0,n){
        int x;cin >> x;
        v.push_back(x);
    }
    rep(i,0,v.size()){
        rep(j,0,v.size()){
            v2.push_back(v[i]+v[j]);
        }
    }
    v2.erase(unique(v2.begin(),v2.end()),v2.end());
    sort(v2.begin(),v2.end());
    int ans=0,k=0;
    //cout << v2.size() << " a " <<  endl;
    bool a=false;
    for(int j=v2.size()-1;j>=0;j--){
        rep(i,k,v2.size()){
            k=i;
            if(v2[i]+v2[j]>m){
                //if(i==(j-1))a=true;
                break;
            }
        ans=max(ans,v2[i]+v2[j]);
        //    cout << an << " a " << endl;
        }
        if(k>j)break;
    }
    cout << ans << endl;
    }
    return;
}

signed main(){
    y();
    return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
#define FS              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll              long long int
#define ld              long double
#define pb              push_back
#define bp              __builtin_popcount
#define sz              size()
#define ff              first
#define ss              second
#define vll             vector<ll>
#define vbool           vector<bool>
#define vpll            vector<pair<ll,ll>>
#define pll             pair<ll,ll>
#define vllv            vector<vector<ll>>
#define setpri(x)       cout<<setprecision(x)<<fixed;
#define all(v)          v.begin(),v.end()
#define allr(v)         v.rbegin(),v.rend()
#define yesr {cout<<"YES"<<endl;return;}
#define nor {cout<<"NO"<<endl;return;}
// getline (std::cin,name);
ll MOD=1e9+7;
ll ceil1(ll n,ll x){return (n-1)/x+(n>0);}

ll gcd(ll a,ll b){return __gcd(a,b);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}

ll pow1(ll n,ll m ,ll mod=MOD );
ll pow2(ll n,ll k);

ll modinv(ll n,ll mod){  return pow1(n,mod-2,mod);}

bool func(pair<ll,ll> &a,pair<ll,ll> &b ){
        if(a.ff != b.ff)return a.ff < b.ff;
        return a.ss > b.ss;
}
ll const N=(ll)2e5+111;
ll const LG=(ll)log2(N)+1;



void solve(){
        ll i,j,k,l,n,m,x,y,z,r;
        
        cin>>n;
        cout<<360/(gcd(n,360));
        
}       
int main(){
        FS;
        
        ll i,j,k,n,m,x,y,z,q;
        q=1;
        // cin>>q;
        while(q--){
                solve();
        }
        return 0;
}


ll pow1(ll n,ll m,ll mod){
        if(m==0)return 1;
        
        if(m%2==0)return pow1((n*n)%mod,m/2,mod);
    	
    	return (pow1((n*n)%mod,m/2,mod)*n)%mod;
}

ll pow2(ll n,ll k){
        ll ans=1;
            while(k>0){
                if(k%2==1)ans=ans*n;
                n=n*n;
                k/=2;
            }
            return ans;
}


Measured memory_bytes: 3652
from sys import stdin
n = stdin.readline().rstrip()
a = [int(x) for x in stdin.readline().rstrip().split()]
b = 0

while True:
   if all([x % 2 == 0 for x in a]):
      a = [x/2 for x in a]
      b += 1
   else:
      break

print(b)

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

/*                    ॐ Shree ॐ                     */
/* ॐ ॐ ॐ
ॐ भूर् भुवः स्वः
तत् सवितुर्वरेण्यं
भर्गो देवस्य धीमहि
धियो यो नः प्रचोदयात्
*/
using namespace std;
typedef long long ll;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
// online submission
#endif
	int n;
	cin>>n;
	vector<int> count(1000000,0);
	int a;
	int mx=0,mn=200001;
	for(int i=0;i<n;i++){
		cin>>a;
		count[a]++;
		mx=max(mx,a);
		mn=min(mn,a);
	}
	vector<int> visited(mx+1,false);
	int cont=0;
	for(int i=mn;i<=mx;i++){
		if(count[i]==1 && visited[i]==false){
			cont++;
		}
		if(count[i]>=1){
			for(int j=i;j<=mx;j+=i){
				visited[j]=true;
			}
		}

	}
	cout<<cont;
}

Measured memory_bytes: 11112
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(15); //"for float-base
  // problem"
  int L, R, d;
  cin >> L >> R >> d;
  cout << (R / d) - ((L - 1) / d) << endl;
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int N; cin >> N;
    string s; cin >> s;
    int cw = 0, cr = 0;
    rep(i, N) if(s[i] == 'R') cr++;
    int res = max(cw, cr);
    rep(i, N){
        if(s[i] == 'W') cw++;
        else cr--;
        res = min(res, max(cw, cr));
    }
    cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 7836
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<string>
#include<sstream>
using namespace std;
int inf = 1000000000;


int main(){

  string s; cin >> s;
  sort(s.begin(), s.end());
  int n = s.size();
  for(int i=0; i<n-1; i++){
    if( s[i] == s[i+1] ){
      cout << "no" << endl;
      return 0;
    }
  }

  cout << "yes" << endl;

  return 0;
}





//


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

int main(void) {
  int X;
  cin >> X;
  bool flag[X + 1] = {0, 1};
  for (int i = 2; i <= X; i++) {
    long long b = i * i;
    while (b <= X) {
      flag[b] = true;
      b *= i;
    }
  }
  for (int i = X; i >= 1; i--) {
    if (flag[i]) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 256
def main():
    r, D, x = map(int, input().split())
    lst = [0] * 11
    lst[0] = x

    for i in range(1, 11):
        lst[i] = r * lst[i - 1] - D

    print(*lst[1:], sep="\n")


if __name__ == "__main__":
    main()


Measured memory_bytes: 61928
// Step.cpp : Defines the entry point for the console application.
//

//#include "stdafx.h"
#include <iostream>
using namespace std;
const int G = 2000* 100 + 10;
int a[G];

int main()
{
	long long int n, s = 0;
	cin >> n;
	cin >> a[0];
	int m=a[0];
	for (int i=1; i<n; i++){
		cin >> a[i];
		if (a[i] < m){
			s += m-a[i];
		}
		m=max(m,a[i]);
	}
	cout << s;
	return 0;
}



Measured memory_bytes: 4372