akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x;
        for(int i = 1; i <= n; i++){
        	x = i;
        if(x % 3 == 0){
        	System.out.print(" " + i);
        	continue;
        }
        while (x > 0) {
        	if(x % 10 == 3){
        		System.out.print(" "+ i);
        		break;
        	}
        	 x /= 10;
        }
        
}
        System.out.println("");
}
}



Measured memory_bytes: 28980
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define int long long
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define f first
#define s second
pair<int,int> a[114514];
signed main(){
	ic(n) ic(k) ic(s)
	rep(0,i,n){
		if(i<k)cout<<s;
		else cout<<114514;
		cout<<" ";
	}
}		

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

int main()
{
  int n, k, r, s, p;
  cin >> n >> k >> r >> s >> p;
  string t;
  cin >> t;
  int ans = 0;

  for (int i = 0; i < n; i++) {
    if (i < k || t[i] != t[i - k]) {
      switch (t[i]) {
      case 'r': ans += p; break;
      case 's': ans += r; break;
      case 'p': ans += s; break;
      }
    } else {
      t[i] = ' ';
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 512
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val x = sc.nextInt()
    val y = sc.nextInt()
    println(problem160d(n, x, y))
}

//fun problem160d(n: Int, x: Int, y: Int): String {
//    val dist = Array(n) { IntArray(n) { -1 } }
//    for (s in 0 until n) {
//        val que = ArrayDeque<Int>()
//        que.offer(s)
//        dist[s][s] = 0
//        while (!que.isEmpty()) {
//            val v = que.poll()
//            val nvs = mutableListOf<Int>()
//            if (v > 0) nvs.add(v - 1)
//            if (v < n - 1) nvs.add(v + 1)
//            if (v == x - 1) nvs.add(y - 1)
//            if (v == y - 1) nvs.add(x - 1)
//            debugLog(s, nvs)
//            for (nv in nvs) {
//                if (dist[s][nv] == -1) {
//                    dist[s][nv] = dist[s][v] + 1
//                    que.offer(nv)
//                }
//            }
//        }
//        debugLog(dist[s].toList())
//    }
//    val res = IntArray(n) { 0 }
//    for (i in 0 until n) {
//        for (j in i + 1 until n) {
//            res[dist[i][j]]++
//        }
//    }
//    return res.drop(1).joinToString("\n")
//}

fun problem160d(n: Int, x: Int, y: Int): String {
    val routes = Array(n) { mutableListOf<Int>() }
    for (i in 0 until n - 1) {
        routes[i].add(i + 1)
        routes[i + 1].add(i)
    }
    routes[x - 1].add(y - 1)
    routes[y - 1].add(x - 1)

    val distances= Array(n - 1) { IntArray(n) { -1 } }

    for (i in 0 until n - 1) {
        val queue = ArrayDeque<Int>()
        queue.offer(i)
        distances[i][i] = 0

        while(!queue.isEmpty()) {
            val current = queue.poll()
            for (j in 0 until routes[current].size) {
                val next = routes[current][j]
                if (distances[i][next] != -1) continue
                distances[i][next] = distances[i][current] + 1
                queue.offer(next)
            }
        }
    }

    val res = IntArray(n) { 0 }
    for (i in 0 until n) {
        for (j in i + 1 until n) {
            res[distances[i][j]]++
        }
    }

    return res.drop(1).joinToString("\n")
}

Measured memory_bytes: 76684
x,y,z,k = gets.split.map &:to_i
a = gets.split.map &:to_i
b = gets.split.map &:to_i
c = gets.split.map &:to_i
ab = a.product(b).map{|l,r| l + r}.sort.reverse
abc = ab[0,k].product(c).map{|l, r| l+r}.sort.reverse
puts abc[0,k]

Measured memory_bytes: 287468
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if(x < y) x = y; }

int main() {
	int N; int M; int L;
	while(~scanf("%d%d%d", &N, &M, &L)) {
		vector<vpii> arcs(N * M);
		rep(i, M) {
			int d; int a; int k; int t;
			scanf("%d%d%d%d", &d, &a, &k, &t);
			arcs[d * N + a].emplace_back(d * N + a + k, t);
		}
		vector<vector<int>> dp(N * M + 1, vector<int>(L + 1, -1));
		dp[0][0] = 0;
		rep(i, N * M) rep(j, L + 1) {
			int x = dp[i][j];
			if(x == -1) continue;
			amax(dp[i + 1][j], x);
			if(j < L) {
				for(auto a : arcs[i])
					amax(dp[a.first][j + 1], x + a.second);
			}
		}
		int ans = *max_element(dp[N * M].begin(), dp[N * M].end());
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 3528
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
using namespace std;
typedef long long ll;

int main(){
    int N;cin>>N;
    ll C;cin>>C;
    vector<ll> x(100010),y(100010),v(100010),L(100010),R(100010),lmax(100010),rmax(100010); 
    //L[i] 時計回りで寿司iまで食べた時のエネルギー
    //lmax[i] 時計回りで寿司iまで食べた時の最大値
    L[0]=x[0]=lmax[0]=0;
    for(int i=1;i<=N;i++){
        cin>>x[i]>>v[i];
        L[i]=L[i-1]+v[i]-(x[i]-x[i-1]);
        lmax[i]=max(L[i],lmax[i-1]);
    }
    R[0]=y[0]=rmax[0]=0;
    for(int i=1;i<=N;i++){
        y[i]=C-x[N+1-i];
        R[i]=R[i-1]+v[N+1-i]-(y[i]-y[i-1]);
        rmax[i]=max(R[i],rmax[i-1]);
    }
    //右側で折り返し
    int i=1;
    ll r_turn=0;
    while(2*y[i]<=C){
        r_turn=max(r_turn,R[i]-y[i]+lmax[N-i]);
        i++;
        if(i==N+1)break;
    }
    //左側で折り返し
    int j=1;
    ll l_turn=0;
    while(2*x[j]<=C){
        l_turn=max(l_turn,L[j]-x[j]+rmax[N-j]);
        j++;
        if(j==N+1)break;
    }

    ll ans=max(max(lmax[N],rmax[N]),max(l_turn,r_turn));
    cout<<ans<<endl;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for(int k=0; k<N; k++)
    cin >> A[k];
  int x=0,y=0;
  
  for(;;){
    for(int j=0; j<N; j++){
      if(A[j]%10%2==0)
        x++;
      else
        break;
    }
    if(x == N){
      for(int l=0; l<N; l++)
        A[l]/=2;
      y++;
    }
    else
      break;
    x=0;
  }
      
  cout << y << endl;
}


Measured memory_bytes: 3596
// imos kyoukai -> subtraction 
// MLEのため row by row 

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

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

int f[2][10101]; 
vector<P> p[10101];

int main(){
    int i,j;
    int n,q;
    while(1){
        cin>>n>>q;
        if(n==0) break;
        memset(f,0,sizeof(f));
        for(i=0;i<10101;i++) p[i].clear();
        int h=0,w=0;
        for(i=0;i<n;i++){
            int a,b,c,d;
            cin>>a>>b>>c>>d;
            a++;
            b++;
            c++;
            d++;
            p[b].pb(P(a,1));
            p[b].pb(P(c,-1));
            p[d].pb(P(a,-1));
            p[d].pb(P(c,1));
            h = max(h, d);
            w = max(w, c);
        }
        int area = 0;
        int length = 0;
        for(i=0;i<h+2;i++){
            memset(f[1], 0, sizeof(f[1]));
            for(P u:p[i]) f[1][u.fi]+=u.se;
            for(j=0;j<w+1;j++){
                f[1][j+1]+=f[1][j];
            }
            for(j=0;j<w+2;j++){
                f[1][j]+=f[0][j];
            }
            for(j=0;j<w+2;j++){
                if(f[1][j]) area++;
                //if(f[1][j]) cout<<i<<" "<<j<<endl;
                if((f[0][j] > 0) != (f[1][j] > 0)) length++;
                if((f[1][j] > 0) != (f[1][j+1] > 0)) length++;
            }
            swap(f[0],f[1]);
        }
        cout<<area<<endl;
        if(q==2) cout<<length<<endl;
    }

}


Measured memory_bytes: 4212
#include <iostream>
#include <string.h>
using namespace std;



int main(){
  
  string t;		//問題文の文字列T
  
  cin >> t;		//tに標準入力
  
  //文字列tに"?"がなければそのままtを出力して、終了
  if(t.find("?") == string::npos){
    cout << t;
    return 0;
  }

  // size_tは配列の長さなどを表すための正の整数のデータ型
  size_t position_hatena;	//"?"の位置

  //文字列tに"?"がある限り、文字の置換処理を続ける
  while(t.find("?") != string::npos){
    if((position_hatena = t.find("?")) != string::npos){
    	t[position_hatena] = 'D';	//"?"の位置を'D'で置換
    }
  }  
  
  cout << t;
  
  return 0;
}

Measured memory_bytes: 3332
#include <bits/stdc++.h>
#define arep(a,i,n) for(ll i=(a);i<(n);i++)
#define rep(i,n) for(ll i=0;i<(n);i++)
#define cinf(x,n) for(ll i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(ll i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

int main(){
	ull x;
	cin >> x;
	if(x%11==0)
		cout << x/11*2 << endl;
	else if(x%11<=6)
		cout << x/11*2+1 << endl;
	else
		cout << x/11*2+2 << endl;
}

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


int main() {
  int n, k; cin >> n >> k;
  int cnt = 0;
  rep(i, n){
    int h; cin >> h;
    if(h >= k) cnt++;
  }
  cout << cnt << endl;
  return 0;
  
}

Measured memory_bytes: 256
num = gets.strip.split.map(&:to_i)
strs = gets.strip.to_s

length = num[0]
tgt_num = num[1]

result = ''
strs.each_char.with_index do |str, index|
  result += index.to_i+1 == tgt_num.to_i ? str.downcase : str.upcase
end
puts result

Measured memory_bytes: 1788
use std::io::*;
use std::str::FromStr;
 
/* 
The read function reads a string according to each one. 
*/
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


//main function
fn main() {
    let hm: i32 = read();
    let wm: i32 = read();
    let h: i32 = read();
    let w: i32 = read();
    println!("{}",hm*wm-h*wm-w*hm+w*h);
}


Measured memory_bytes: 4352
#include<stdio.h>
#define N 100

int main(){
  int i,j,graph[N][N]={},n,out,u,next;

  scanf("%d",&u);

  for(i=0;i<u;i++){
    scanf("%d %d",&n,&out);

    for(j=0;j<out;j++){
      scanf("%d",&next);

      graph[n-1][next-1]=1;
    }
  }
  for(i=0;i<u;i++){

	for(j=0;j<u-1;j++) printf("%d ",graph[i][j]);

    printf("%d",graph[i][u-1]);
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 648
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
    int n,m;
    int ans=0;
    cin >>n>>m;
    vector<int>yen(m,0);
    rep(i,m){
        cin>>yen[i];
    }
    sort(all(yen));
    vector<int>dp(n+3,INF);
    dp[0]=0;
    rep(i,m){
        for(int j=0;j<n+1;j++){
            if(j>=yen[i]){
                chmin(dp[j],dp[j-yen[i]]+1);
               
            }
           // clog << dp[j] << " ";
        }
        //clog << endl;
    }
    cout<<dp[n]<<endl;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(a) int((a).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
const int mod = 1e9 + 7;
template<class T, class U> inline void add_self(T &a, U b){a += b;if (a >= mod) a -= mod;if (a < 0) a += mod;}
template<class T, class U> inline void min_self(T &x, U y) { if (y < x) x = y; }
template<class T, class U> inline void max_self(T &x, U y) { if (y > x) x = y; }

#define _deb(x) cout<<x;
void _print() {cerr << "]\n";} template <typename T, typename... V>void _print(T t, V... v) {_deb(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
template <class T, class U> void print_m(const map<T,U> &m, int w=3){if(m.empty()){cout<<"Empty"<<endl; return;}for(auto x: m)cout<<"("<<x.first<<": "<<x.second<<"),"<<endl;cout<<endl;}
template<class T, class U>void debp(const pair<T, U> &pr, bool end_line=1){cout<<"{"<<pr.first<<" "<<pr.second<<"}"; cout<<(end_line ? "\n" : ", ");}
template <class T> void print_vp(const T &vp, int sep_line=0){if(vp.empty()){cout<<"Empty"<<endl; return;}if(!sep_line) cout<<"{ ";for(auto x: vp) debp(x,sep_line);if(!sep_line) cout<<"}\n";cout<<endl;}
template <typename T>void print(const T &v, bool show_index = false){int w = 2;if(show_index){for(int i=0; i<sz(v); i++)cout<<setw(w)<<i<<" ";cout<<endl;}for(auto &el: v) cout<<setw(w)<<el<<" ";cout<<endl;}
template <typename T>void print_vv(const T &vv){if(sz(vv)==0) {cout<<"Empty"<<endl; return;} int w = 3;cout<<setw(w)<<" ";for(int j=0; j<sz(*vv.begin()); j++)cout<<setw(w)<<j<<" ";cout<<endl;int i = 0;for(auto &v: vv){cout<<i++<<" {";for(auto &el: v) cout<<setw(w)<<el<<" ";cout<<"},\n";}cout<<endl;}

ll powMod(ll n, ll p) {
    assert(p>=0);
    ll res = 1;
    while (p) {
        if (p & 1) (res *= n) %= mod;
          (n *= n) %= mod;
        p >>= 1;
    }
    return res;
}

const int MAXN = 1e6+10;
vl fact(MAXN), inv(MAXN), finv(MAXN), p2(MAXN), p8(MAXN);

void precalc(){
    int n = MAXN;
    fact[0] = finv[0] = inv[1] = 1;
    p2[0] = p8[0] = 1;
    fore(i, 2, n)
        inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;
    fore(i, 1, n){
        fact[i] = fact[i-1] * i % mod;
        finv[i] = finv[i-1] * inv[i] % mod;
        p2[i] = p2[i-1]*2%mod;
        p8[i] = p8[i-1]*8%mod;
    }
}

ll C(int n, int r){
    if(n<r || r<0) return 0;
    return fact[n] * finv[r]%mod * finv[n-r]%mod;
}

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    precalc();
    ll n;
    while(cin>>n){
        ll ans = 0;
        fore(i,2,n+1){
            ll cur = C(n,i)*(p2[i] - 2 + mod)%mod * p8[n-i]%mod;
            ans = (ans+cur+mod)%mod;
        }
        cout<<ans<<"\n";
    }
    return 0;
}

Measured memory_bytes: 42176
#include <stdio.h>
int main (void)
{
    int a,b,c,x,y,z;
    scanf("%d %d %d",&a,&b,&c);

    if(a>b){
        x=a;
        a=b;
        b=x;       
    };

    if(b>c){
        y=b;
        b=c;
        c=y;
    };

    if(a>b){
        z=a;
        a=b;
        b=z;
    };

    printf("%d %d %d\n",a,b,c);
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define lli long long int
#define MOD 1000000007
#define inf 2147483647
#define infll LLONG_MAX
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<int>
#define vvi vector<vector<int>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
using namespace std;

lli modFact(lli n, lli mod = MOD){
    if(n == 0) return 1;
    else return n * modFact(n-1) % mod;
}

lli modPow(lli x, lli n, lli mod = MOD){
    if(n == 0) return 1;
    if(n%2 == 0) return modPow(x*x%mod, n/2, mod)%mod;
    return x%mod * modPow(x%mod, n-1, mod)%mod;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    lli n, a, b, total;
    cin >> n >> a >> b;
    total = modPow(2, n, MOD) -1;

    // Pattarn: a
    lli sum = 1;
    for(int i=n; i>=n-a+1; i--) sum = sum * i % MOD;
    a = (sum * modPow(modFact(a), MOD-2)) % MOD;

    // Pattarn: b
    sum = 1;
    for(int i=n; i>=n-b+1; i--) sum = sum * i % MOD;
    b = (sum * modPow(modFact(b), MOD-2)) % MOD;

    total = total - a - b;
    while(total < 0) total += MOD;
    cout << total%MOD << endl;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
using LL=long long;
int main(){
  int N;
  LL A[100005];
  cin>>N;
  for(int i=0;i<N;i++)scanf("%lld",&A[i]);
  sort(A,A+N);
  
  LL ans1=0,ans2=0;
  {
  int a=0,b=N-1;
  a++;
  LL p=A[0],q=A[0];
  for(int i=1;;){
    if(b-a<=0){
      if(b==a)ans1+=A[b]-min(p,q);
      break;
    }
    ans1+=(A[b])+(A[b-1])-(p+q);
    p=A[b],q=A[b-1];
    b-=2;
    if(b-a<=0){
      if(b==a)ans1+=max(p,q)-A[a];
      break;
    }
    ans1+=(p+q)-(A[a]+A[a+1]);
    p=A[a],q=A[a+1];
    a+=2;
  }
  }
  
  {
  int a=0,b=N-1;
  b--;
  LL p=A[N-1],q=A[N-1];
  for(int i=1;;){
    if(b-a<=0){
      if(b==a)ans2+=max(p,q)-A[a];
      break;
    }
    ans2+=(p+q)-(A[a]+A[a+1]);
    p=A[a],q=A[a+1];
    a+=2;
    if(b-a<=0){
      if(b==a)ans2+=A[b]-min(p,q);
      break;
    }
    ans2+=(A[b])+(A[b-1])-(p+q);
    p=A[b],q=A[b-1];
    b-=2;
  }
  }
  cout<<max(ans1,ans2)<<endl;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    struct P
    {
        int x;
        int y;
        public P(int x,int y)
        {
            this.x = x;
            this.y = y;
        }
    }
    static void Main(string[] args)
    {
        var hw = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var gre = new string[hw[0]];
        var count = 0;
        for (var i = 0; i < hw[0]; i++)
        {
            gre[i] = ReadLine();
            count += gre[i].Count(c => c == '#');
        }
        int x = 0, y = 0, nextx = 0, nexty = 0;
        var set = new HashSet<P>();
        while (x != hw[1] - 1 || y != hw[0] - 1)
        {
            var isP = false;
            set.Add(new P(x, y));
            if (x != hw[1] - 1 && gre[y][x + 1] == '#')
            {
                isP = true;
                nextx++;
            }
            if (y != hw[0] - 1 && gre[y + 1][x] == '#')
            {
                if (isP) { WriteLine("Impossible");return; }
                isP = true;
                nexty++;
            }
            if (isP) { x = nextx;y = nexty; }
            else { WriteLine("Impossible");return; }
        }
        WriteLine(set.Count==count-1?"Possible":"Impossible");
    }
}


Measured memory_bytes: 13396
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);

    int n, K;
    cin >> n >> K;
    vector<int> bad(10, false);
    for (int i = 0; i < K; ++i) {
        int x;
        cin >> x;
        bad[x] = true;
    }
    
    auto ok = [&](int x) {
        while (x != 0) {
            if (bad[x % 10]) {
                return false;
            }
            x /= 10;
        }
        return true;
    };


    int res = -1;

    for (int i = n; ;++i) {
        if (ok(i)) {
            res = i;
            break;
        }
    }


    cout << res << '\n';


    return 0;
}

Measured memory_bytes: 3580
#include <iostream>
using namespace std;
int main(void)
{
  int W, H, x, y, r;
  cin >> W;
  cin >> H;
  cin >> x;
  cin >> y;
  cin >> r;

  if (x >= 0 && y >= 0 && x - r <= W && x + r <= W && y - r <= H && y + r <= H)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}


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

int N;
char S[114514];
int G[114514];
int X[114514];
bool used[114514];
vector<int> es[114514];
int M;

int dfs(int v) {
  if (used[v]) return 0;
  used[v] = true;

  int sum = X[v]%26;
  for (int u : es[v]) {
    if (used[u]) continue;
    sum += dfs(u);
    sum %= 26;
  }
  return sum;
}

int ToIdx(int b) {
  //assert(b >= 1);
  if (N%2 == 1) {
    if (b <= N/2) return b;
    return N-b;
  } 

  if (b <= N/2) return b;
  return N-b;
}

int main() {
  scanf("%s", S);
  N = strlen(S);
  scanf("%d", &M);
  for (int i=0; i<M; i++) {
    int a;
    int b;
    scanf("%d%d", &a, &b);
    --a;
    --b;
    int u = ToIdx(a);
    int v = ToIdx(b+1);
    if (u == v) continue;
    es[u].emplace_back(v);
    es[v].emplace_back(u);
  }

  G[0] = S[0]-'a';
  for (int i=1; i<N; i++) {
    G[i] = (26+(S[i]-S[i-1])%26)%26;
    int k = ToIdx(i);
    X[k] += G[i];
    X[k] %= 26;
  }

  /*printf("G: ");
  for (int i=0; i<N; i++) {
    printf("%d ", G[i]);
  }puts("");
  printf("X: ");
  for (int i=0; i<N; i++) {
    printf("%d ", X[i]);
  }puts("");*/

  dfs(0);
  for (int i=1; i<=N/2; i++) {
    if (!used[i]) {
      //printf("i: %d\n", i);
      int res = dfs(i);
      //printf("res: %d\n", res);
      if (res%26) {
        puts("NO");
        return 0;
      }
    }
  }
  puts("YES");
}


Measured memory_bytes: 7168
#include <cstdio>

using namespace std;

int main() {
    int n, cnt = 0, p;
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &p);
        if (i - p) ++cnt;
    }
    printf("%s\n", cnt <= 2 ? "YES" : "NO");
    return 0;
}


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

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, k;
	cin >> n >> k;
	vector<int> l(n);
	for (auto&& li : l) cin >> li;
	sort(l.begin(), l.end(), greater<int>());
	int sum = 0;
	for (int i = 0; i < k; i++) sum += l[i];
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <random>
#include <set>
#include <stack>
#include <time.h>

//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater<vector<int>>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple

using namespace std;
using ll = long long;
typedef std::pair<int, int> pii;
typedef std::pair<int, double> pid;
typedef std::vector<int> vi;
typedef std::vector<pii> vii;

#define PI 3.14159265358979323846264338327950L
const int mod = 1000000007;




void solve(){
    int n,m;
    cin >> n >> m;
    
    vector<vector<int>> g(3*n);
    rep(i,m){
        int u,v;
        cin >> u >> v;
        u--,v--;
        g[u].eb(n+v);
        g[n+u].eb(2*n+v);
        g[2*n+u].eb(v);
    }
    int s,t;
    cin >> s >> t;
    s--,t--;
    
    
    queue<int> Q;
    Q.push(s);
    int cnt = 0;
    int v[300100] = {};
    while(!Q.empty()){
        int sz = Q.size();
        cnt++;
        rep(ii,sz){
            int now = Q.front();
            Q.pop();
            for(auto next :g[now]){
                if (next == t){
                    cout << cnt/3;
                    rn;
                }
                if (v[next]) continue;
                Q.push(next);
                v[next] = 1;
            }
        }
    }
    
    cout << -1;
    
    
    
}


int main() {
    int T;
    //cin >> T;
    T = 1;
    while (T--) {
        solve();
        cout << endl;
    }
}














Measured memory_bytes: 20524
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
using namespace std;

string T;
int main(){
    cin >> T;
    string ans = "";
    for(int i = 0;i < T.length();i++){
        if(T[i] == '?'){
            ans += 'D';
        }else{
            ans += T[i];
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3920
#include<iostream> 
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>
//#define _LIBCPP_DEBUG 0
//#define _GLIBCXX_DEBUG
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)	
using namespace std;

int max(int a, int b) {
	int max;
	if (a > b) max = a;
	else max = b;
	return max;
}
int min(int a, int b) {
	int min;
	if (a < b) min = a;
	else min = b;
	return min;
}


int main() {

	ll a, b, x;
	cin >> a >> b >> x;
	ll ans = 0;
	if (a % x == 0) {
		ans = (b / x) - a / x + 1;
	}
	else {
		ans = (b / x) - (a / x);
	}

	cout << ans << endl;





	return 0;

}

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

ll a,b;
ll x;

int main(){ 

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

cin>>a>>b>>x;

if(a%x==0){
	cout<<(b/x)-(a/x)+1<<endl;
}
else{
	cout<<(b/x)-(a/x)<<endl;
}

}


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

int main() {
	int a, b;
	while (cin >> a >> b, a | b) {
		int c[100]{};
		for (int d = 0; d < a; d++) {
			int e; cin >> e;
			for (int f = 0; f < e; f++) {
				int g; scanf("%d", &g);
				c[g - 1]++;
			}
		}
		int x = 0, y = 0;
		for (int i = 0; i < 100; i++) {
			if (c[i] > x) { x = c[i]; y = i + 1; }
		}
		if (x >= b)cout << y << endl;
		else puts("0");
	}
}

Measured memory_bytes: 3212
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[] l = new Integer[N];
    for (int i=0; i<N; i++) {
      l[i] = sc.nextInt();
    }
    Arrays.sort(l,Collections.reverseOrder());
    int total =0;
    for (int i=0; i<K; i++) {
      total += l[i];
    }
    System.out.println(total);
  }
}

Measured memory_bytes: 22740
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define MOD 1000000007
using namespace std;

int main(void){
    int a,b,c;
    cin >> a >> b >> c;
    cout << (a*b)/2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n,x,t;
    scanf("%d %d %d", &n,&x,&t);
    n += (x-1);
    printf("%d", (n/x) * t);
    
    return 0;
}


Measured memory_bytes: 3220
[N,M,C] = list(map(int,input().split()))
B = list(map(int,input().split()))
A = []
for i in range(N):
    A.append(list(map(int,input().split())))

cnt = 0
for i in range(N):
    S = 0
    for j in range(M):
        S+=A[i][j]*B[j]
    S+=C
    if S>0:
        cnt+=1
print(cnt)


Measured memory_bytes: 38384
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<functional>
#include<iostream>
#include<map>
#include<queue>
#include<string>
#include<vector>
using namespace std;
char c,o;
int ans;
int main()
{
	c=getchar();
	cout<<c;
	while(c!='\n')
	{
		o=c;
		c=getchar();
		ans++;
	}
	cout<<ans-2<<o;
	return 0;
}


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

using namespace std;

int main(){
	int n;
	cin>>n;
	int res = n % 10;
	if(res ==2||res==4||res==5||res==7||res==9)
	cout<<"hon"<<endl;
	else if(res== 3)
	cout<<"bon";
	else cout<<"pon";
	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
const ll MOD = 1000000007;//998244353;
const ll SIZE = 26;
ll power(ll x, ll n, ll M = MOD){
    ll res = 1;
    if(n > 0){
        res = power(x, n / 2, M);
        if(n%2 == 0)res = (res * res) % M;
        else res = (((res * res) % M) * x) % M;
    }
    return res;
}
ll mod_inv(ll n, ll M=MOD){
    return power(n, M-2, M);
}


int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   ll k; cin >> k;
   string s; cin >> s;
   ll size_s = s.size();
   vector<ll> power25, power26;
   power25.push_back(1);
   power26.push_back(1);
   rep(i,2000000){
      power25.push_back(power25[i] * (SIZE-1));
      power26.push_back(power26[i] * SIZE);
      power25[i+1] %= MOD;
      power26[i+1] %= MOD;
   }
   vector<ll> nCk;
   nCk.push_back(1);
   rep(i, k){
      nCk.push_back((nCk[i]*(size_s+i)%MOD)*mod_inv(i+1));
      nCk[i+1] %= MOD;
   }
   ll ans = 0;
   for (ll i = size_s; i <= size_s+k; i++){
      ll y = nCk[i-size_s] * power25[i-size_s];
      y %= MOD;
      y *= power26[size_s+k-i];
      y %= MOD;
      ans += y;
      ans %= MOD;
   }
   cout << ans << endl;
}

Measured memory_bytes: 51408
#include <iostream>

using namespace std;

int main(){
    string l1, l2;
    int count = 0;
    cin >> l1;
    cin >> l2;
    for(int i=0;i<l1.size();i++){
      string str = "";
      for(int j=i;j<i+l2.size();j++){
        str += l1[j%l1.size()];
        //cout << str << endl;
      }
      if(str==l2){
        count += 1;
      }
    }
    if(count)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 3172
#include <fstream>
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <assert.h>
#include <string>
#include <set>
#include <unordered_map>

using namespace std;


typedef pair<int, int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;


#define ALL(a) a.begin(),a.end()
const int INF = 1e9, sze = 5e3 + 100, N = 11;
const ll MOD1 = 998244353;





signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int n, k;
	cin >> n >> k;
	vi left, right;

	for (int i = 0; i < n; ++i)
	{
		int a;
		cin >> a;

		if (a < 0)
			left.push_back(a);
		else if (a > 0)
			right.push_back(a);
		else
			k--;
	}

	if (!k)
	{
		cout << "0\n";
		return 0;
	}

	int ans = INF;

	if (left.size() >= k)
		ans = min(ans, -left[left.size() - k]);

	if (right.size() >= k)
		ans = min(ans, right[k - 1]);

	for (int l = max(1, k - (int)right.size()); l <= min(k - 1, (int)left.size()); ++l)
	{
		int cnt = -left[left.size() - l] - left[left.size() - l] + right[k - l - 1];
		ans = min(ans, cnt);
	}

	for (int r = max(1, k - (int)left.size()); r <= min(k - 1, (int)right.size()); ++r)
	{
		int cnt = -left[left.size() - (k - r)] + 2 * right[r - 1];
		ans = min(ans, cnt);
	}

	cout << ans;
}

Measured memory_bytes: 1020
from bisect import bisect_left, bisect_right

H, W, M = map(int,input().split())
targets = [list(map(lambda x: int(x) - 1, input().split())) for i in range(M)]

cnth = [0] * H
cntw = [0] * W
wlist = [[] for i in range(H)]

for i in range(M):
	hi, wi = targets[i]
	cnth[hi] += 1
	cntw[wi] += 1
	wlist[hi].append(wi)

maxhi = []
maxwi = []
maxh = max(cnth)
maxw = max(cntw)

for i in range(H):
	wlist[i].sort()
	if cnth[i] == maxh:
		maxhi.append(i)
for i in range(W):
	if cntw[i] == maxw:
		maxwi.append(i)

for i in range(len(maxhi)):
	for j in range(len(maxwi)):
		if bisect_right(wlist[maxhi[i]], maxwi[j]) - bisect_left(wlist[maxhi[i]], maxwi[j]) == 0:
			print(maxh + maxw)
			exit()
print(maxh + maxw - 1)

Measured memory_bytes: 196516
import java.util.*;

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

		int[] b = new int[code2];
		int num = 0;
		int num2 =0;
		int sum = 0;
		int count = 0;

		for(int i = 0;i < code2;i++){
			b[i] = sc.nextInt();
		}

		for(int i = 0;i<code;i++){
			for(int j=0;j<code2;j++){
				num = sc.nextInt();
				num2 = b[j]*num;
				sum += num2;
			}
			if(sum + c > 0)
			count++;
			sum = 0;
		}

		System.out.println(count);
	}
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  int h, w, a, b;
  cin >> h >> w >> a >> b;
  vector<string> ar(h, string(w, '0'));
  for (int j = 0; j < a; ++j) {
    for (int i = b; i < h; ++i) {
      ar[i][j] = '1';
    }
  }
  for (int i = 0; i < b; ++i) {
    for (int j = a; j < w; ++j) {
      ar[i][j] = '1';
    }
  }
  for (auto s: ar) {
    cout << s << endl;
  }
}

Measured memory_bytes: 2304
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define inf 1145141919364364
#define double long double
using namespace std;
typedef pair<ll, ll>P;
ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
signed main() {
	ll a, b;
	cin >> a >> b;
	if (a <= 5)cout << 0 << endl;
	else if (a >= 13)cout << b << endl;
	else cout << b / 2 << endl;
	ggr
}


Measured memory_bytes: 256
//実装できなくて答え見た
//きれいなコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;
const ll MOD = 1000000007;
// const ll INF = 1000000000000000000LL;

int main() {
  string s;
  vector<string> cand = {"dreamer", "eraser", "dream", "erase"};
  cin >> s;
  reverse(s.begin(), s.end());
  rep(i, 4) reverse(cand[i].begin(), cand[i].end());
 
  bool flag = true;
  while (flag) {
    flag = false;
    // cerr << s << endl;
    rep(i, 4) {
      if (s.substr(0, cand[i].size()) == cand[i]) {
        s.erase(0, cand[i].size());
        flag = true;
        break;
      }
    }
  }
  cout << (s.size() == 0 ? "YES" : "NO") << endl;
  return 0;
}

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

using vi = vector<int>;
using vl = vector<long long int>;
using vii = vector<vector<int>>;
using vll = vector<vector<long long int>>;
#define pb push_back;
#define mp make_pair;
/*ll powM(ll a,ll b,ll m)
{
    ll ans=1;
    a%=m;
    while(b)
        {
            if(b&1)ans=ans*a%m;
            a=a*a%m;
            b>>=1;
        }
        return ans;
}
*/


int main(){
      ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.precision(2);
cout<<fixed;
ll s,w;cin>>s>>w;
if(w>=s)cout<<"unsafe"<<"\n";
else cout<<"safe"<<"\n";
 return 0;


}

Measured memory_bytes: 3548
#include<bits/stdc++.h>
using namespace std;
unordered_set<int>s;
int main(){
  	int n;
	ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin>>n;
	int f=0;
	for(int i=0;i<n;i++){
		int k;
		cin>>k;
		if(s.find(k)==s.end()){
			s.insert(k);
		}
		else f=1;
	}
	if(f==1)puts("NO");
	else puts("YES");
	return 0;
}

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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef long long lli;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, str>> vpls;
typedef vector<tuple<str, ll, ll>> vtsl;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

vector<ll> enum_div(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;
}

//実行部
void Main()
{
  ll n; cin >> n;
  ll ans = 0;
  for(ll i = 1;i <= n;i += 2)
  {
    vll a = enum_div(i);
    if(a.size() == 8) ans++;
  }
  fin(ans)
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

using namespace std;

#define INF 2140000000
#define MOD 1000000007

int main() {
	int r, c;
	char mat2[1003][1003];

	for (int i = 0; i < 1003; ++i) {
		for (int j = 0; j < 1003; ++j) {
			mat2[i][j] = '#';
		}
	}

	cin >> r >> c;

	vector<string> mat(r);
	vector<pair<int, int> > p;

	int cnt = 0;
	

	for (int i = 0; i < r; ++i) {
		cin >> mat[i];

		for (int j = 0; j < c; ++j) {
			mat2[i + 1][j + 1] = mat[i][j];

			if (mat[i][j] == '#') {
				p.push_back(make_pair(i, j));
				cnt++;
			}
		}
	}

	int ops = 0;

	while (cnt < r * c) {
		ops++;
		vector<pair<int, int> > p2;

		for (vector<pair<int, int> >::iterator it = p.begin(); it != p.end(); ++it) {
			int rr = (*it).first + 1;
			int cc = (*it).second + 1;

			if (mat2[rr][cc - 1] == '.') {
				mat2[rr][cc - 1] = '#';
				p2.push_back(make_pair(rr - 1, cc - 2));
				cnt++;
			}

			if (mat2[rr + 1][cc] == '.') {
				mat2[rr + 1][cc] = '#';
				p2.push_back(make_pair(rr, cc - 1));
				cnt++;
			}

			if (mat2[rr][cc + 1] == '.') {
				mat2[rr][cc + 1] = '#';
				p2.push_back(make_pair(rr - 1, cc));
				cnt++;
			}

			if (mat2[rr - 1][cc] == '.') {
				mat2[rr - 1][cc] = '#';
				p2.push_back(make_pair(rr - 2, cc - 1));
				cnt++;
			}
		}	

		p = p2;
	}

	cout << ops << endl;

	return 0;
}

Measured memory_bytes: 15620
#include <cmath>
#include<iostream>
#include <functional>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <iomanip>
using namespace std;
 
int main(){    
  long long A1,A2,A3;
  cin >> A1 >> A2 >> A3;

  if(A1+A2+A3 >= 22){
  cout << "bust" << endl;
  }
  else{
    cout << "win" << endl; 
  }
}


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

min_div = 10 ** 9 
for a in A:
    div_count = 0
    while a % 2 == 0:
        a /= 2
        div_count += 1
    min_div = min(min_div, div_count)

print(min_div)

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

#define pb push_back
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define digits(x) floor(log10(x) + 1)
#define countbits(x) ((int)log2(x)+1)
#define forn(i, n) for (int i = 0; i < (int)(n); i++)
#define init(arr,value) memset(arr,value,sizeof(arr))
#define deb(x) cout << #x << "=" << x << endl;
#define test unsigned int tet;cin >> tet;while(tet--)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout.precision(10);cout << fixed;
#define int long long

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 9;
const ll N   = 500500;

string temp,a[1005];
int dp[1005][1005];

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

        for(int i=1; i<=n; i++){
            cin >> temp;
            a[i].pb('#');
            for(auto ch : temp){
                a[i].pb(ch);
            }
        }

        dp[0][1] = 1;

        for(int i=1; i<=n; i++){
            for(int j=1; j<=m; j++){
                if(a[i][j] == '#'){
                    dp[i][j] = 0;
                }
                else{
                    dp[i][j] = (dp[i-1][j] + dp[i][j-1])%MOD;
                }
            }
        }

        cout << dp[n][m];

    	return 0;
}



Measured memory_bytes: 13168
#!/usr/bin/env python3
from collections import deque
import sys
try:
    from typing import Deque, List
except ImportError:
    pass


def bfs(G: "List[List[int]]", a: int):
    q = deque()  # type: Deque[int]
    q.append(a)
    dist = [-1] * len(G)
    dist[a] = 0
    while q:
        s = q.popleft()
        for t in G[s]:
            if dist[t] >= 0:
                continue
            q.append(t)
            dist[t] = dist[s] + 1
    return dist


def solve(N: int, a: "List[int]", b: "List[int]"):
    G = [[] for i in range(N)]
    for ai, bi in zip(a, b):
        ai -= 1
        bi -= 1
        G[ai].append(bi)
        G[bi].append(ai)
    db = bfs(G, 0)
    dw = bfs(G, N - 1)
    bn = sum((dbi <= dwi) for dbi, dwi in zip(db, dw))
    wn = N - bn
    if bn > wn:
        print("Fennec")
    else:
        print("Snuke")


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int()] * (N - 1)  # type: "List[int]"
    b = [int()] * (N - 1)  # type: "List[int]"
    for i in range(N - 1):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(N, a, b)


if __name__ == '__main__':
    main()


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

typedef complex<double> Point;
typedef vector<Point> VP;
#define X real()
#define Y imag()
const double EPS = 1e-10;
#define EQ(n,m) (abs((n)-(m)) < EPS)

double dot(Point a, Point b) {
  return a.X*b.X + a.Y*b.Y;
}

double cross(Point a, Point b) {
  return a.X*b.Y - a.Y*b.X;
}

namespace std {
  bool operator<(const Point a, const Point b) {
    return a.X != b.X ? a.X < b.X : a.Y < b.Y;
  }
}

int ccw(Point a, Point b, Point c) {
  b -= a;  c -= a;
  if (cross(b,c) >  EPS) return +1;  // counter clockwise
  if (cross(b,c) < -EPS) return -1;  // clockwise
  if (dot(b,c)   < -EPS) return +2;  // c--a--b on line
  if (norm(b) < norm(c)) return -2;  // a--b--c on line or a==b
  return 0;                          // a--c--b on line or a==c or b==c
}

Point crosspointLL(Point a1, Point a2, Point b1, Point b2) {
  double d1 = cross(b2-b1, b1-a1);
  double d2 = cross(b2-b1, a2-a1);
  if (EQ(d1, 0) && EQ(d2, 0)) return a1;  // same line
  assert(!EQ(d2, 0)); // ???????????????
  return a1 + d1/d2 * (a2-a1);
}

// ???????§???¢?????????????????°
VP convexCut(const VP& ps, Point a1, Point a2) {
  int n = ps.size();
  VP ret;
  rep(i,n) {
    int ccwc = ccw(a1, a2, ps[i]);
    if (ccwc != -1) ret.push_back(ps[i]);
    int ccwn = ccw(a1, a2, ps[(i + 1) % n]);
    if (ccwc * ccwn == -1) ret.push_back(crosspointLL(a1, a2, ps[i], ps[(i + 1) % n]));
  }
  return ret;
}

double area(const VP& ps) {
  double a = 0;
  rep (i, ps.size()) a += cross(ps[i], ps[(i+1) % ps.size()]);
  return a / 2;
}

int main(void){
    int n,q;
    double x,y;
    cin>>n;
    VP ch(n);
    rep(i,n){
        cin>>x>>y;
        ch[i] = {x,y};
    }

    cin>>q;
    rep(i,q){
        double x1,y1,x2,y2;
        cin>>x1>>y1>>x2>>y2;
        VP cc = convexCut(ch,Point(x1,y1),Point(x2,y2));
        printf("%.9f\n",area(cc));
    }
    
    return 0;
}

Measured memory_bytes: 3360
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

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

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

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

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

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:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        pos: [(i64, i64, i64); n],
    }
    let mut h_star = 0;

    for cx in 0..101 {
        'inner: for cy in 0..101 {
            for i in 0..n {
                let (x, y, h) = pos[i];
                if h == 0 {
                    continue;
                }

                h_star = h + (cx - x).abs() + (cy - y).abs();
                break;
            }
            for i in 0..n {
                if max(h_star - (cx - pos[i].0).abs() - (cy - pos[i].1).abs(), 0) != pos[i].2 {
                    continue 'inner;
                }
            }
            println!("{} {} {}", cx, cy, h_star);
            return;
        }
    }
}


Measured memory_bytes: 4352
n, m = map(int, input().split())
num = [-1] * n
ans = 0

for i in range(m):
    s, c = map(int, input().split())
    if num[s-1] == c or num[s-1] == -1:
        num[s-1] = c
    else:
        ans = -1
        break
    
if n == 1 and num[0] <= 0:
    num[0] = 0
if n >= 2:
    if num[0] == 0:
        ans = -1
    elif num[0] == -1:
        num[0] = 1

        
if not ans == -1:
    l = ''
    for j in num:
        if j == -1:
            l += '0'
        else:
            l += str(j)
    ans = int(l)        
print(ans)
    

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNING
//#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>

// #include <stack>
// #include <queue>
// #include <set>
// #include <tuple>
// #include <list>
// #include <numeric>
// #include <random>
// #include <regex>
// #include <utility>

using namespace std;
const int INF = (int)1e9;

//#define DEBUG

void solution() {
	string s;
	cin >> s;
	if (s == "Sunny") {
		cout << "Cloudy";
	}
	else if (s == "Cloudy") {
		cout << "Rainy";
	}
	else {
		cout << "Sunny";
	}
}

int main() {
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
	solution();
  return 0;		
}


Measured memory_bytes: 256