akhauriyash/Code-Regression huggingface dataset:
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function main()
	n = readline() |> parseInt
	k = 0
	for i in 1:n
		if 1<=i<10 || 100<=i<1000 || 10000<=i<100000
			k += 1
		end
	end
	println(k)
end

main()

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

#define             ll  long long
#define            ull  unsigned long long
#define            P_B  push_back
#define            M_P  make_pair
#define             vi  vector<int>
#define             vl  vector<ll>
#define            vii  vector<pair<int, int> >
#define            vll  vector<pair<ll, ll> >
#define            pii  pair<int, int>
#define            pll  pair<ll, ll>
#define         DBG(x)  printf("%s %d\n", #x, x)
#define       DBGLL(x)  printf("%s %lld\n", #x, x)
#define         SCI(x)  scanf("%d",&x)
#define         SCD(x)  scanf("%lf",&x)
#define         SCS(x)  scanf("%s",x)
#define         CLR(x)  memset(x, 0, sizeof(x))
#define        CLRN(x)  memset(x, -1, sizeof(x))
#define        SCLL(x)  scanf("%lld", &x)
#define      FOR(i, n)  for(int i = 0; i < n; i++)
#define  FORR(i, m, n)  for(int i = m; i < n; i++)
#define     SCI2(m, n)  scanf("%d%d", &m, &n)
#define  SCI3(m, n, o)  scanf("%d%d%d",&m, &n, &o)
#define     SCD2(m, n)  scanf("%lf%lf",&m,&n)
#define  SCD3(m, n, o)  scanf("%lf%lf%lf",&m,&n,&o)
#define    SCLL2(m, n)  scanf("%lld%lld", &m, &n)
#define SCLL3(m, n, o)  scanf("%lld%lld%lld",&m, &n, &o)

#define            Mod  1000000007
#define            INF  100000000



int main()
{
	string s;
	int d;
	cin >> s >> d;
	int len = s.size();
	ll dp[105][2];
	CLR(dp);
	dp[0][0] = 1;
	FOR(i, len){
		ll tdp[105][2];
		CLR(tdp);
		FOR(j, d){
			FOR(k, 10){
				if(k == s[i] - '0'){
					tdp[(j+k)%d][0] += dp[j][0];
					tdp[(j+k)%d][0] %= Mod;
				}
				if(k < s[i]-'0'){
					tdp[(j+k)%d][1] += dp[j][0];
				}
				tdp[(j+k)%d][1] += dp[j][1];
				tdp[(j+k)%d][1] %= Mod;
			}
		}
		FOR(j, d){
			dp[j][0] = tdp[j][0];
			dp[j][1] = tdp[j][1];
		}
	}
	ll ans = (dp[0][0] + dp[0][1])%Mod;
	--ans;
	if(ans < 0) ans = Mod - 1;
	printf("%lld\n", ans);
}

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

using std::pair;
using std::vector;
using std::string;

typedef long long ll;
typedef pair<int, int> pii;

#define fst first
#define snd second
#define pb(a) push_back(a)
#define mp(a, b) std::make_pair(a, b)
#define debug(...) fprintf(stderr, __VA_ARGS__)

template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }

const int oo = 0x3f3f3f3f;

string procStatus() {
    std::ifstream t("/proc/self/status");
    return string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
}

template <typename T> T read(T& x) {
    int f = 1; x = 0;
    char ch = getchar();
    for(;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
    return x *= f;
}

const int N = 4000;

int st[N + 5], to[N + 5], nxt[N + 5], ecnt = 1;

inline void addedge(int u, int v) {
    to[++ ecnt] = v; nxt[ecnt] = st[u]; st[u] = ecnt;
    to[++ ecnt] = u; nxt[ecnt] = st[v]; st[v] = ecnt;
}

bool get_p(int u, int fa, int t, vector<int>& p) {
    if(u == t) return true;

    for(int i = st[u]; i; i = nxt[i]) {
        int v = to[i];
        if(v == fa || !get_p(v, u, t, p)) continue;

        p.pb(i);
        return true;
    }
    return false;
}

int n, m;
int cnt[N + 5];
int x[N + 5], y[N + 5];
vector<int> p[N + 5], q[N + 5];

bool dir[N + 5], used[N + 5];

int main() {
#ifdef Wearry
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif

    read(n), read(m);
    for(int i = 1; i < n; ++i) {
        static int u, v;
        read(u), read(v);
        addedge(u, v);
    }

    for(int i = 1; i <= m; ++i) {
        read(x[i]), read(y[i]);
        get_p(x[i], 0, y[i], p[i]);
        for(auto e : p[i]) ++ cnt[e >> 1], q[e >> 1].pb(i);
    }

    int ans = 0;
    for(int i = 1; i < n; ++i) ans += std::min(cnt[i], 2);

    while(true) {
        int eid = 0, pid;
        for(int i = 1; i < n; ++i) {
            if(cnt[i] == 1 && dir[i << 1] != dir[i << 1 | 1]) {
                eid = dir[i << 1] ? (i << 1 | 1) : (i << 1);
                break;
            }
        }

        if(!eid) {
            for(int i = 1; i < n; ++i) {
                if(cnt[i]) { eid = i << 1; break; }
            }
            if(!eid) break;
        }

        bool rev = 0;
        while(used[q[eid >> 1].back()]) q[eid >> 1].pop_back();

        used[pid = q[eid >> 1].back()] = true;

        for(auto e : p[pid]) if((e >> 1) == (eid >> 1)) {
            rev = e ^ eid;
        }

        if(rev) {
            std::swap(x[pid], y[pid]);
            for(auto& e : p[pid]) e ^= 1;
        }

        for(auto e : p[pid]) -- cnt[e >> 1], dir[e] = true;
    }

    printf("%d\n", ans);
    for(int i = 1; i <= m; ++i) printf("%d %d\n", x[i], y[i]);

    return 0;
}


Measured memory_bytes: 13952
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = -1*((1LL<<63)+1);
const int inf = -1*((1<<31)+1);

using namespace std;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<int> count; //それぞれ何個の島を辿れるか

    UnionFind(int N) : par(N+1), count(N+1) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i, count[i] = 1;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    int size(int x) {
        return count[root(x)]; 
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        if (size(rx) < size(ry)) swap(rx, ry);
        count[rx] += count[ry]; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
        par[ry] = rx;
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

};


int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,M,ans = 0;
    cin >> N >> M;
    vector<pair<ll,ll>> a(N);
    UnionFind uni(N);
    vector<bool> used(N);

    rep(i,N){
        cin >> a[i].first;
        a[i].second = i;
    }
    rep(i,M){
        int x,y;
        cin >> x >> y;
        uni.unite(x,y);
    }

    if( (N-1-M)*2 > N ){
        cout << "Impossible" << endl;
        return 0;
    }
    if(N-1 == M ){
        cout << 0 << endl;
        return 0;
    }
    sort(ALL(a));
    set<int> st;
    int cnt = 0;
    rep(i,N){
        if(st.count(uni.root(a[i].second))){
            if(cnt < N - M - 2) ans += a[i].first, cnt++;
        }else{
            st.insert(uni.root(a[i].second));
            ans += a[i].first;
        }
    }
    cout << ans << endl;
}

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

for h in range(1,3501):
    if (4*h <= N):
        continue
    nn = int (N*h / (4*h-N))
    for n in range(max(1,nn),3501):
        t = 4*h*n - N*h - N*n
        if t <= 0:
            continue
        s = N*h*n
        if s % t == 0:
            print(h, n, int(s/t))
            quit()

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

class Main {
        public static void main(String[] args) throws Exception {
                BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
                int n = Integer.parseInt(br.readLine());
                System.out.println((long)Math.pow(n,3));
        }
}


Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;

int main(){
  int n;
  cin >> n;
  
  vector<int> w(n);
  for(int i = 0; i < n; i++){
    cin >> w.at(i);
  }


  int zettai = 0;
  int min = 100000000;
  for(int i = 0; i < n; i++){
    int sum1 = 0;
    int sum2 = 0;

    for(int j = 0; j < i; j++){
      sum1 += w.at(j);
    }
    for(int j = i; j < n; j++){
      sum2 += w.at(j);
    }
  
    if(sum1 - sum2 > 0)
      zettai = sum1 - sum2;
    else
      zettai = sum2 - sum1;

    if(min > zettai)
      min = zettai;
    //cout << zettai << ' ' << min << endl;
  }

  cout << min << endl;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define maxs(x,y) x = max(x, y)
#define mins(x,y) x = min(x, y)
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int H, W, N;
    cin >> H >> W >> N;

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

    vector<vector<int>> ans(H, vector<int> (W));
    int x = 0;
    REP(i, N) {
        REP(j, a[i]) {
            int ni = x/W, nj = x%W;
            if (ni & 1) nj = W-nj-1;
            ans[ni][nj] = i + 1;
            x++;
        }
    }

    REP(i, H) {
        REP(j, W) {
            cout << ans[i][j] << " ";
        }
        cout << endl;
        
    }


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

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

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

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n,k;
  cin>>n>>k;
  vector<Int> a(n);
  for(Int i=0;i<n;i++) cin>>a[i];

  auto calc=[&](Int y){              
              Int x=(y==0);
              for(Int i=0;i<n;i++) if(i!=y&&a[i]<a[x]) x=i;
              return x;
            };
  auto NG=[](){cout<<-1<<endl;exit(0);};
  vector<Int> ans;

  Int c=calc(-1);
  for(Int j=0;j<n;j++)
    if(j!=c) ans.emplace_back(j),a[j]--;
  ans.emplace_back(c),a[c]--;
    
  for(Int i=0;i<k;i++){
    Int d=calc(c);
    for(Int j=0;j<n;j++)
      if(j!=c&&j!=d) ans.emplace_back(j),a[j]--;
    ans.emplace_back(d),a[d]--;
    c=d;
  }
  
  for(Int i=0;i<n;i++) if(a[i]<0) NG();
  
  cout<<ans.size()<<endl;
  for(Int i=0;i<(Int)ans.size();i++){
    if(i) cout<<" ";
    cout<<ans[i]+1;
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
l = [1]
a = 6
b = 9
while True:
    if a > 100000:
        break
    else:
        l.append(a)
        l.append(b)
        a *= 6
        b *= 9

dp = [[10000000]*(n+1) for i in range(len(l)+1)]
dp[0][0] = 0
for i in range(len(l)):
    for j in range(n+1):
        if j < l[i]:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = min(dp[i][j],dp[i+1][j-l[i]]+1)
print(dp[len(l)][n])

Measured memory_bytes: 30196
//#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>
#include <climits>

using namespace std;
using ll=long long;

void solve(){
  int num,k;
  cin >> num >> k;
  int res=0;
  for(int i=0;i<num;i++){
    int x;
    cin >> x;
    res+=2*min(x,k-x);
  }
  cout << res << endl;
}

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


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <deque>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define print(x) cout<<(x)<<endl
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define INF10 1001001001 
#define INF5 100000
#define EPS 1e-10


int main() {
	int N; cin >> N;
	vector<int>H(N);
	REP(i, N) cin >> H[i];
	int mx = 0;
	int cnt = 0;
	int cur = H[0];
	REP(i, N-1) {
		if (H[i] < H[i + 1]) {
			if (mx < cnt) mx = cnt;
			cnt = 0;
		}
		else {
			cnt++;
		}
	}
	mx = max(cnt, mx);
	cout << mx << endl;



	return 0;
}


Measured memory_bytes: 640
import sys
import numpy as np
 
if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
 
n=int(input())
s=input()
cnt=0

for i in range(n-2):
	if s[i]=="A" and s[i+1]=="B" and s[i+2]=="C":
		cnt+=1

print(cnt)

Measured memory_bytes: 12488
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int ac = 0, wa = 0, tle = 0, re = 0;
		for(int i = 0; i <= n; i++){
			String s = sc.nextLine();
			switch(s){
			case "AC":
				ac++;
				break;
			case "WA":
				wa++;
				break;
			case "TLE":
				tle++;
				break;
			case "RE":
				re++;
				break;
			default:
				break;
			}
		}
		System.out.println("AC x " + ac);
		System.out.println("WA x " + wa);
		System.out.println("TLE x " + tle);
		System.out.println("RE x " + re);
	}
}

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

using namespace std;

#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define mp make_pair
#define pb push_back
#define fi first
#define se second

const int maxn = 703;

int n, m;
int vs[maxn], col[maxn];
vector<pair<int, int> > has;
vector<int> adj[maxn];
int D[maxn][maxn];
int cnt[2];
int G;

int cmp(pair<int, int> a, pair<int, int> b) {
  if (a.fi > a.se) swap(a.fi, a.se);
  if (b.fi > b.se) swap(b.fi, b.se);
  return a.se - a.fi > b.se - b.fi;
}

void dfs(int u, int co) {
  if (vs[u]) {
    if (col[u] != co) {
      cout << -1;
      exit(0);
    }
    return;
  }
  vs[u] = 1;
  cnt[co]++;
  col[u] = co;
  for (auto v : adj[u]) {
    dfs(v, co ^ 1);
  }
}

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

  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    x--; y--;
    D[x][y] = 1;
    D[y][x] = 1;
  }

  rep(i, 0, n) {
    rep(j, 0, n) {
      if (i == j) continue;
      if (D[i][j] == 0) adj[i].pb(j);
    }
  }

  rep(i, 0, n) {
    if (!vs[i]) {
      G++;
      cnt[0] = cnt[1] = 0;
      dfs(i, 0);
      has.pb(mp(cnt[0], cnt[1]));
    }
  }

  int cur1 = 0, cur2 = 0;

  sort(has.begin(), has.end(), cmp);

  rep(i, 0, G) {
    if (cur1 > cur2) swap(cur1, cur2);
    cur1 += max(has[i].fi, has[i].se);
    cur2 += min(has[i].fi, has[i].se);
  }

  int ans = ((cur1 * (cur1 - 1)) / 2) + ((cur2 * (cur2 - 1)) / 2); 
  cout << ans;

  return 0;
}


Measured memory_bytes: 3072
#累積和を使用
def main(n,k,p):
    maxVal = 0
    #期待値リスト・累積和リストの初期化
    kitai = [0] * n
    ruiseki = [0] * n
    kitai[0] = (p[0] + 1) / 2
    ruiseki[0] = (p[0] + 1) / 2
    #期待値・累積和の計算
    for i in range(1, n):
        kitai[i] = (p[i] + 1) / 2
        ruiseki[i] = ruiseki[i-1] + kitai[i]
    #累積和を使用して最大となる値を探索
    for i in range(k-1, n):
        val = ruiseki[i] - (ruiseki[i-k] if i-k >= 0 else 0)
        maxVal = max(maxVal, val)
    return maxVal

n,k = map(int, input().split())
p = list(map(int,input().split()))
print(main(n,k,p))

Measured memory_bytes: 25056
n=int(input())
b=list(map(int,input().split()))
a=[0]*n
for i in range(n):
    if i==0:
        a[i]=b[i]
    elif 0<i<n-1:
        a[i]=min(b[i-1],b[i])
    else:
        a[i]=b[i-1]
print(sum(a))

Measured memory_bytes: 8836
#include <iostream>
#include <bits/stdc++.h>
#define endl "\n"
#define int long long
#define pii pair<int,int>
using namespace std;

const int Mod = 1e9+7;

signed main() {
    int n,k;cin>>n>>k;
    int a[n];
    bool ok=1;
    for(int i=0;i<n;i++){
    	cin>>a[i];
    	if(i>=k){
    		if(a[i]<=a[i-k]) cout<<"No"<<endl;
    		else cout<<"Yes"<<endl;
    	}
    }
}

Measured memory_bytes: 5152
import sys
input = sys.stdin.readline
from collections import Counter



def main():
    N = int(input())
    V = [int(x) for x in input().split()]

    ac = Counter()
    bc = Counter()
    for i in range(N):
        if i & 1:
            ac[V[i]] += 1
        else:
            bc[V[i]] += 1

    acm = ac.most_common()
    bcm = bc.most_common()

    if acm[0][0] != bcm[0][0]:
        print(N // 2 - acm[0][1] + N // 2 - bcm[0][1])
    else:
        ans = float("inf")
        for i in acm:
            if i[0] == bcm[0][0]:
                continue
            ans = min(ans, N // 2 - i[1] + N // 2 - bcm[0][1])

        for j in bcm:
            if acm[0][0] == j[0]:
                continue
            ans = min(ans, N // 2 - j[1] + N // 2 - acm[0][1])
        if ans == float("inf"):
            print(N // 2)
        else:
            print(ans)


if __name__ == '__main__':
    main()



Measured memory_bytes: 22252
n = int(input())
l = [0 for _ in range(100)]
ans = 0
for i in range(1,n+1):
    l[int(str(i)[0]+str(i)[-1])]+=1
for i in range(10):
    for j in range(10):
        ans+=l[i*10+j]*l[j*10+i]
print(ans)

Measured memory_bytes: 3060
from itertools import product
H, W, K = map(int, input().split())
A = [[0 for j in range(W+1)] for i in range(H+1)]
M = 10 ** 9 + 7
A[0][1] = 1


if W == 1:
    print(1)
    exit()

cache = {}


def xyz(x):
    x -= 2
    if cache.get(x) is not None:
        return cache[x]
    X, Y, Z = 0, 0, 0
    for i in product('01', repeat=W-1):
        s = ''.join(i)
        if s.find('11') != -1:
            continue
        if x == -1:
            if s[0] == '1':
                Z += 1
            else:
                Y += 1
            continue
        if W - 2 == x:
            if s[-1] == '1':
                X += 1
            else:
                Y += 1
            continue
        t = s[x:x+2]
        if t == '10':
            X += 1
        elif t == '01':
            Z += 1
        else:
            Y += 1
    cache[x] = (X, Y, Z)
    return X, Y, Z


for h in range(H+1):
    for x in range(1, W+1):
        if H < h + 1:
            continue
        X, Y, Z = xyz(x)
        A[h + 1][x - 1] += (X * A[h][x]) % M
        A[h + 1][x] += (Y * A[h][x]) % M
        if W < x + 1:
            continue
        A[h + 1][x + 1] += (Z * A[h][x]) % M


print(A[H][K] % M)

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

#define pb push_back

#define int ll
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vpii = vector<pii>;
using vvpii = vector<vpii>;

template<typename T, typename U>
ostream& operator<<(ostream& o, const pair<T,U>& p) {
  return o << "(" << p.first << "," << p.second << ")";
}

template<typename T>
ostream& operator<<(ostream& o, const vector<T>& v) {
  o << "[";
  for (const T& x : v)
    o << x << ",";
  return o << "]";
}

const int INF = 1e18;

int pow5(int n) {
  return n*n*n*n*n;
}

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

  int x;
  cin >> x;
  for (int a=-200; a<=200; ++a) {
    for (int b=-200; b<=200; ++b) {
      if (pow5(a) - pow5(b) == x) {
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }
  assert(false);
}


Measured memory_bytes: 3652
N = int(input())
a = [int(i) for i in input().split()]
b = [0 for i in range(N)]

a = [0] + a
b = [0] + b

m = N // 2

for i in range(N, 0, -1):
    tmp = 0
    for j in range(i, N+1, i):
        tmp += b[j]
    if a[i] != tmp % 2:
        b[i] = 1
    
ans = []
for i in range(1, N+1):
    if b[i] > 0:
        ans.append(i)

if len(ans) == 0:
    print(0)
else:
    print(len(ans))
    for i in range(len(ans)):
        if i == 0:
            print(ans[i], end="")
        else:
            print(" ", end="")
            print(ans[i], end="")
            

Measured memory_bytes: 12720
#include <stdio.h>
#include <stdlib.h>
#define int long long

int N, K, *A;

int max(int a, int b){
//	printf("(a, b) = (%lld, %lld)\n", a, b);
	return a >= b ? a : b;
}

int only_one_dig_sum(int d, int b){
	int i, ans = 0;
	for(i = 0; i < N; i++){
		ans += ((b << d) ^ (A[i] & ((int)1 << d)));
	}
//	printf("ans[%lld][%lld] = %lld\n", d, b, ans);
	return ans;
}

int solve_sub(int d){
	if(d < 0){
		return 0;
	}
	else{
		return max(only_one_dig_sum(d, 0), only_one_dig_sum(d, 1)) + solve_sub(d - 1);
	}
}

int solve(int d){
//	printf("d = %lld\n", d);
	if(d < 0){
		return 0;
	}
	else if((((int)1 << d) & K) == 0){
//		printf("test3\n");
		return only_one_dig_sum(d, 0) + solve(d - 1);
	}
	else{
//		printf("test4\n");
		return max(only_one_dig_sum(d, 1) + solve(d - 1), only_one_dig_sum(d, 0) + solve_sub(d - 1));
	}
}

signed main(){
	int i;
	scanf("%lld%lld", &N, &K);
	A = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		scanf("%lld", &A[i]);
	}
//	printf("solve(%lld) = %lld\n", (int)2, solve(2));
//	printf("solve(%lld) = %lld\n", (int)1, solve(1));
//	printf("solve(%lld) = %lld\n", (int)0, solve(0));
	printf("%lld\n", solve(50));
	return 0;
}

Measured memory_bytes: 896
N = int(input())
A = input()
B = input()
C = input()

ans = 0
for i in range(N):
    if(A[i] == B[i] and B[i] == C[i]):
        continue
    elif(A[i] != B[i] and B[i] != C[i] and C[i] != A[i]):
        ans += 2
    else:
        ans += 1

print(ans)


Measured memory_bytes: 3060
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 c = sc.nextInt();
        if(a < b && b < c) System.out.println("Yes");
        else System.out.println("No");
    }
}


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

class TestClass {
	static void Main(string[] args) {
		int[] num = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
		if(num[0] < num[1]) {
			Console.WriteLine("a < b");
		}else if(num[0] > num[1]) {
			Console.WriteLine("a > b");
		}else{
			Console.WriteLine("a == b");
		}
	}
}


Measured memory_bytes: 9272
#include <iostream>
#include <vector>
#include <tuple>
#include <deque>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <algorithm>
#include <unordered_set>
#define int long long
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()

using namespace std;

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

void fast()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

signed main()
{
	fast();
	int x;
	cin >> x;
	vector <int> d(3005);
	d[0] = 1;
	for (int i = 0; i < x; ++i) 
	{
		vector <int> smth(1);
		for (int j = 0; j <= x; ++j) 
		{
			smth.push_back((smth.back() + d[j]) % MOD);
		}
		for (int j = 3; j <= x; ++j) 
		{
			d[j] = smth[j - 2] % MOD;
		}
	}

	cout << d[x] << '\n';
	return 0;
}

Measured memory_bytes: 3668
#include <cstdio>
#define INF 5e4

int a,b,d;

int main(void){
	while(1){
		scanf("%d %d %d",&a,&b,&d);
		if(a+b+d==0)break;
		int x=INF,y=INF;
		for(int i=0;i<=50000;i++){
			int k=(d-a*i)/b;
			if(k>=0){
				if(a*i+b*k==d){
					if(i+k<x+y){
						x=i;
						y=k;
					}else if(i+k==x+y && a*i+b*k<x*a+b*y){
						x=i;
						y=k;
					}
				}
			}
			k=(d+a*i)/b;
			if(k>=0){
				if(b*k==d+a*i){
					if(i+k<x+y){
						x=i;
						y=k;
					}else if(i+k==x+y && a*i+b*k<x*a+b*y){
						x=i;
						y=k;
					}
				}
			}
			k=(a*i-d)/b;
			if(k>=0){
				if(b*k+d==a*i){
					if(i+k<x+y){
						x=i;
						y=k;
					}else if(i+k==x+y && a*i+b*k<x*a+b*y){
						x=i;
						y=k;
					}
				}
			}
		}
		printf("%d %d\n",x,y);
	}
	return 0;
}

Measured memory_bytes: 1028
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>

using namespace std;

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

    for (int i = 0; i < 4; i++) {
        cout << str[i];
    }
    cout << " ";
    for (int i = 4; i < 12; i++) {
        cout << str[i];
    }
    cout << endl;


    return 0;
}

Measured memory_bytes: 256
#include<cstdio>

int n;

int main(){
	while(1){
		int A,B,Aanswer=0,Banswer=0;
		scanf("%d",&n);
		if(n==0)return 0;
		for(int i=0;i<n;i++){
			scanf("%d %d",&A,&B);
			if(A>B)Aanswer+=A+B;
			else if(A<B)Banswer+=A+B;
			else{
				Aanswer+=A;
				Banswer+=B;
			}
		}
		printf("%d %d\n",Aanswer,Banswer);
	}
	return 0;
}

Measured memory_bytes: 1028
#include <iostream>
#include <string>
#include <map>
#include <vector>
using namespace std;

int main(){
    // word[s] で 文字列sの出現回数が返ってくる
    map<string, int> word;
    vector<string> v;
    string s;
    
    while( cin >> s ){
        v.push_back(s);
        
        //入力した単語がすでにあるか探す
        // countはすでに文字列sがキーとして存在すれば1が、そうでなければ0が返ってくる
        if( word.count(s) ){ 
            word[s]++;
        }else{
            word[s] = 1;
        }
    }
    // 最頻出の単語を調べる
    int mode = 0;
    for(int i=0 ; i < v.size() ; i++ ){
        mode = max( mode , word[ v[i] ] );
    }
    for(int i=0 ; i < v.size() ; i++ ){
        if( mode == word[ v[i] ] ){
            cout << v[i];
            break;
        }
    }
    // 最長の単語を求める
    int length = 0;
    for(int i=0 ; i < v.size() ; i++ ){
        // v[i].size()で返ってくる数値はint型でなくsize_t型なので注意！
        length = max( length , (int)v[i].size() );
    }
    for(int i=0 ; i < v.size() ; i++ ){
        if( length == v[i].size() ){
            cout << " " << v[i] << endl;
        }
    }
}

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

using namespace std;

int main(){
  int K, A, B;
  cin >> K >> A >> B;
  
  int KA = A/K;
  int KB = B/K;
  
  string ret = "OK";
  if (KA == KB && A % K != 0) ret = "NG"; 
  
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 3624
def divisor(n):
    divisors = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
    return divisors

n = int(input())
ans = 0
for i in range(1, n + 1, 2):
    if len(divisor(i)) == 8:
        ans += 1
  
print(ans)

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

bool all_zero(vector<int>v){
    for(int i=0;i<v.size();i++){
        if(v[i]!=0)return false;
    }
    return true;
}

int main(){
    int n; cin>>n;
    vector<int>h(n);
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    h.push_back(0);
    int ans=0,L,R,min=9999;
    while(!all_zero(h)){
        L=0;
        while(h[L]==0){
            L++;
        }
        R=L;
        min=9999;
        while(h[R]!=0){
            if(h[R]<min)min=h[R];
            R++;
        }
        ans+=min;
        for(int i=L;i<R;i++){
            h[i]-=min;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int INF = 1001001001;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll limit;
  cin >> limit;
  limit--;
  string res;
  while(limit >= 0) {
    res += (char)(limit % 26 + 'a');
    limit /= 26;
    limit--;
  }
  reverse(res.begin(), res.end());
  cout << res << endl;
  return 0;
}

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

//vector <long long> v[1000000];

//stack <long long> pus, wyn;

queue <long long> qu;

long long int  x[1000000], y, z, czy=0, w, n, m=1000000007;
char s[10][10];

int main()
{
    long long int a, b, c, d, k, i, j, q, t, p;

//    q=1;


//    scanf("%lld", &q);
//    for(t=0; t<q; t++)
    {
        scanf("%lld%lld", &n, &k);
        for(i=0; i<n; i++)scanf("%lld", &x[i]);

        sort(x, x+n);

        reverse(x, x+n);

        w=997;



        if(x[0]<0 && k%2==1)
        {
            w=1;
            for(i=0; i<k; i++)w=(m+(w*x[i])%m)%m;
        }
        else
        {
            a=0;
            b=1;
            w=1;
            if(k%2==1)
            {
                w=x[0];
                a=1;
            }
            k++;
            while(a+b<k)
            {
                if(x[n-b]*x[n-b-1]>x[a]*x[a+1])
                {
                    w*=x[n-b];
                    w=w%m;
                    w*=x[n-b-1];
                    b+=2;
                    w=w%m;
                }
                else
                {
                    w*=x[a];
                    w%=m;
                    w*=x[a+1];
                    a+=2;
                    w=w%m;
                }
            }
        }
        printf("%lld\n", (w+m)%m);
    }

    return(0);
}


Measured memory_bytes: 5364
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 競プロ_Csharp {
    class Program {
        static void Main(string[] args) {

            int[] a = nextIntsLine();
            println((a[0] * a[1]) + " " + (2 * a[0] + 2 * a[1]));

        }

        public static void println (Object o) {
            Console.WriteLine(o);
        }

        public static int nextIntLine () {
            return int.Parse(Console.ReadLine());
        }

        public static int[] nextIntsLine () {
            return Console.ReadLine().Split().Select(int.Parse).ToArray();
        }
    }
}



Measured memory_bytes: 16248
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>
#include <unordered_map>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define rep_down(i, n) for(int i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(int i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";
/*
for (iterator = hash.begin(); iterator != hash.end(); iterator++)
{
// ここで、要素毎の操作を行います。
std::pair<std::string, CMyClass> element = *iterator;

}
*/
/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

ll gcd(ll a, ll b){
  ll tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
  ll N, M, A, B, C, D, E, F, K,L, W, H, P, Q, R, X, Y;
  ll ans;
  string S, T;
  cin >>R;
  cout << R*R << endl;
  
  
  
   




}


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

bool kaibun(string T, int M){
  bool judge = true;
  int L=(M+1)/2;
  for(int i=0; i<L  ;i++){
    if( T.at(i) != T.at(M-i-1)){
      judge = false;
      break;
    }
  }
  return judge;
}

int main(){

string S;
cin >> S;
int N = S.size();
string ans;

if(kaibun(S,N) && kaibun(S,(N-1)/2)){
  ans = "Yes";
}
else{
  ans = "No";
}

cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextLong()
    println(problem101b(n))
}

fun problem101b(n: Long): String {
    val nStr = n.toString()
    var sn = 0
    nStr.forEach {
        sn += it.toString().toInt()
    }
    return if (n % sn == 0L) "Yes" else "No"
}

Measured memory_bytes: 31388
// ABC162B - FizzBuzz Sum

#include <bits/stdc++.h>
using namespace std;

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

	long long int ans = 0;

	for (int i = 1; i <= N; i++) {
		if ((i % 3 != 0)&&(i % 5 != 0)){
			ans += i;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
struct Point{
    double x,y;
    Point(){}
    Point(double x,double y):x(x),y(y){}
};
typedef Point Vector;
Vector operator + (Vector A,Vector B){
    return Vector(A.x+B.x,A.y+B.y);
}
Vector operator - (Vector A,Vector B){
    return Vector(A.x-B.x,A.y-B.y);
}
Vector operator * (Vector A,double p){
    return Vector(A.x*p,A.y*p);
}
Vector operator / (Vector A,double p){
    return Vector(A.x/p,A.y/p);
}
bool operator < (const Point& a,const Point& b){
    return a.x<b.x||(a.x==b.x&&a.y<b.y);
}
const double eps = 1e-10;
int dcmp(double x){
    if(fabs(x)<eps) return 0; else return (x<0?-1:1);
}
bool operator == (const Point& a,const Point& b){
    return dcmp(a.x-b.x)==0 && dcmp(a.y-b.y)==0;
}
//点积
double Dot(Vector A,Vector B){
    return A.x*B.x+A.y*B.y;
}
double Length(Vector A){
    return sqrt(Dot(A,A));
}
double Angle(Vector A,Vector B){
    return acos(Dot(A,B)/Length(A)/Length(B));
}
 
//叉积
double Cross(Vector A,Vector B){
    return (A.x*B.y-A.y*B.x);
}
//三角形面积的二倍的叉乘公式
double Area2(Point A,Point B,Point C){
    return Cross(B-A,C-A);
}
//向量旋转,rad是弧度
Vector Rotate(Vector A,double rad){
    return Vector(A.x*cos(rad)-A.y*sin(rad),A.x*sin(rad)+A.y*cos(rad));
}
//计算向量的单位法线,先逆时针旋转90度，然后把长度归一化
Vector Normal(Vector A){
    double Len=Length(A);
    return Vector(-A.y/Len,A.x/Len);
}
//求两直线交点
//调用前请确保P+tv和Q+tw有唯一交点，当且仅当Cross(v,w)非0
Point GetLineIntersection(Point P,Vector v,Point Q,Vector w){
    Vector u=P-Q;
    double t=Cross(w,u)/Cross(v,w);
    return P+v*t;
}
//点到直线的距离
double DistanceToLine(Point P,Point A,Point B){
    Vector v1=B-A,v2=P-A;
    return fabs(Cross(v1,v2))/Length(v1);
}
//点到线段的距离
double DistanceToSegment(Point P,Point A,Point B){
    if(A==B) return Length(P-A);
    Vector v1=B-A,v2=P-A,v3=P-B;
    if(dcmp(Dot(v1,v2))<0) return Length(v2);
    else if(dcmp(Dot(v1,v3))>0) return Length(v3);
    else return fabs(Cross(v1,v2))/Length(v1);
}
//点在直线上的投影
Point GetLineProjection(Point P,Point A,Point B){
    Vector v=B-A;
    return A+v*(Dot(v,P-A)/Dot(v,v));
}
//反射
Point GetLineReflection(Point P,Point A,Point B){
    return GetLineProjection(P,A,B)*2-P;
}
//判断两线段严格相交
bool SegmentProperIntersection(Point a1,Point a2,Point b1,Point b2){
    double c1=Cross(a2-a1,b1-a1), c2=Cross(a2-a1,b2-a1),
           c3=Cross(b2-b1,a1-b1), c4=Cross(b2-b1,a2-b1);
    return dcmp(c1)*dcmp(c2)<0 && dcmp(c3)*dcmp(c4)<0;
}
//判断点是否在线段上
bool OnSegment(Point P,Point a1,Point a2){
    return dcmp(Cross(a1-P,a2-P))==0 && dcmp(Dot(a1-P,a2-P))<=0;
}
int main(){
    int t;
    cin>>t;
    while(t--){
        Point A,B,C,D;
        cin>>A.x>>A.y>>B.x>>B.y>>C.x>>C.y>>D.x>>D.y;
        bool ans1=SegmentProperIntersection(A,B,C,D);
        bool ans2=OnSegment(A,C,D)||OnSegment(B,C,D)||OnSegment(C,A,B)||OnSegment(D,A,B);
        if(ans1||ans2) cout<<1;
        else cout<<0;
        cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vector<int>>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define pii pair<int, int>
#define vpli vector<pair<long long, int>>
#define deb(x) cout << "deb " << #x << " " << x << endl;
#define all(x) x.begin(), x.end()
#define endl "\n"
const ll BIG = 1e18;

void swap(ll &a, ll &b)
{
    ll t = a;
    a = b;
    b = t;
}

ll Min(ll a, ll b, ll c)
{
    return min(a, min(b, c));
}

void printvec(vi &vec)
{
    for (int x : vec)
    {
        cout << x << " ";
    }
    cout << endl;
}

int sum(int a)
{
    int ans = 0;
    while (a)
    {
        ans += (a % 10);
        a = a / 10;
    }
    return ans;
}
void print(vi &mp)
{
    for (auto x : mp)
    {
        cout << x;
    }
    cout << endl;
}
void solve()
{
    ll n;
    cin >> n;
    ll ans = 0;
    for(ll i=2;i*i<=n;i++)
    {
        int power = 0;
        while(n%i == 0)
        {
            power++;
            n = n/i;
        }
        int reqd = 1;
        while(power>=reqd)
        {
            ans ++;
            power -= reqd;
            reqd++;
        }
    }
    if(n!=1) ans++;
    cout<<ans<<endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1;
    //cin >> t;
    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 3664
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC target("avx,avx2")
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//# include <x86intrin.h>
# include <bits/stdc++.h>

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

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int n, m, k;
int cnt[N];
string s;
int a[N];
vector < int > g[N];
int u[N];
int ans, res;
int cur;



int main () {
	SpeedForce;
	string t;
	cin >> s >> t;
	t.pop_back();
	if(s==t) cout << "Yes\n";
	else cout << "No\n";

	return Accepted;
}

// B...a

Measured memory_bytes: 17724
#include<bits/stdc++.h>
#define mx 100005
using namespace std;

int main(){
	int n, k, t[mx], st[mx], ans = 1000000005;
	scanf("%d%d", &n, &k);
	for(int i = 0; i < n; i++){
		scanf("%d", &t[i]);
	}
	sort(t, t+n);
	for(int i = 0; i <= n-k; i++){
		ans = min(ans, t[i+k-1] - t[i]);
	}
	printf("%d", ans);
}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;
const int INT_INF = 1e9;
const ll INF = 1LL << 30;
const ll MOD = 1e9 + 7;

using Graph = vector<vector<int>>;
vector<bool> seen;
void dfs(const Graph &g, int v, P<int, int> &p){
    seen[v] = true;
    for(auto next_v : g[v]){
        if(seen[next_v]) continue;
        if(p.first == v && p.second == next_v) continue;
        if(p.second == v && p.first == next_v) continue;
        dfs(g, next_v, p);
    }
}

int main() {
    int n, m; cin >> n >> m;
    Graph g(n);
    V<P<int, int> > p(m);
    for(int i = 0; i < m; i++){
        int a, b; cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
        p[i] = make_pair(a, b);
    }

    int ans = 0;
    seen.assign(n, false);
    for(int i = 0; i < m; i++){
        dfs(g, 0, p[i]);

        bool flag = false;
        for(int i = 0; i < n; i++){
            if(seen[i]) continue;
            flag = true;
            break;
        }
        if(flag) ans++;
        seen.assign(n, false);
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
using System;
namespace pro
{
    class MainClass
    {
        public static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            string[] str = Console.ReadLine().Split(' ');
            int[] h = new int[n];
            for(int i = 0; i < n; i++)
            {
                h[i] = int.Parse(str[i]);
            }
           
            for (int i = n-1; i >0; i--)
            {
                if (h[i-1] > h[i])
                {

                        h[i-1]--;

                 
                }

            }
            bool b = true;

            for (int i = n-1; i >0; i--)
            {
                if (h[i-1] > h[i])
                {
                    b = false;
                }
            }
            if (n == 1)
            {
                Console.WriteLine("Yes");
            }
            else if (b)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

        }
    }
}

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

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>
#include <queue>
#include <stack>

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)
#define SORT(s) sort(s.begin(), s.end())
#define P pair<int, int>
#define mp make_pair

const double INF = 1e+09;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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 gcd(int a, int b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));}

int lcm(int a, int b)
{return a * b / gcd(a, b);}

vector<int> uniq(vector<int> vec){
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return vec;}

vector<ll> divisor(ll n) {
vector<ll> ret;
for(int64_t 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 permu(int n){
  vector<int> perm(n);
  REP(i, n) perm[i] = i;
do{
  cout << perm  << endl;
}
while (next_permutation(perm.begin(), perm.end()));
return;}

vector<pair<ll, int>> prime_div(ll n){
  vector<pair<ll, int>> res;
  for (ll i=2; i*i <= n;i++){
    if (n%i == 0){
      int a = 0;
      while(n%i == 0){
        n /= i;
        a++;
      }
      pair<ll, int> tmp;
      tmp.first = i;
      tmp.second = a;
      res.push_back(tmp);
    }
  }
  if (n != 1){
    pair<ll, int> now;
    now.first = n;
    now.second = 1;
    res.push_back(now);}
  return res;
}


// printf("%.10f\n" , ans);
int main(void){
  ios::sync_with_stdio(false);
  ll a, b, v, w, t;
  cin >> a >> v >> b >> w >> t;
  ll now = abs(a- b);
  ll val = (v-w) * t;
  if (now <= val) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}



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

#define debug(x) cerr << x << " = "(x) << endl;
#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll x,k,d; cin >> x >> k >> d;
    if( abs(x) / d >= k ) {
        cout << abs(x) - k * d << endl;
        return 0;
    }
    ll pnt = abs(x) / d; //回数
    k -= pnt;
    x = abs(x) - pnt * d;
    if(k % 2 == 1) {
        cout << abs( x - d) << endl;
    }else {
        cout << x << endl;
    }

}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define cinf(x,n) for(int i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(int 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(){
	ll n;
	cin >> n;
	if(n%1000)
		cout << 1000-n%1000 << endl;
	else
		cout << 0 << endl;
}

Measured memory_bytes: 3632
#ABC 175 C
x, k, d = map(int, input().split())

x = abs(x)
syou = x // d
amari = x % d

if k <= syou:
    ans = x - (d * k)

else:
    if (k - syou) % 2 == 0: #残りの動ける数が偶数
        ans = amari

    else:#残りの動ける数が奇数
        ans = abs(amari - d)

print(ans)

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    string s;cin>>s;
    int a=0,b=s.size()-1;
    while(s[a]!='A')a++;
    while(s[b]!='Z')b--;
    cout<<b-a+1<<endl;
}


Measured memory_bytes: 640
N=int(input())
table=[]
for i in range(N):
    a,b,c=map(int,input().split())
    table.append((a,b,c))
dp0=[0]*(N+1)
dp1=[0]*(N+1)
dp2=[0]*(N+1)
for i in range(1,N+1):
    a,b,c=table[i-1]
    dp0[i]=max(dp1[i-1]+a,dp2[i-1]+a)
    dp1[i]=max(dp0[i-1]+b,dp2[i-1]+b)
    dp2[i]=max(dp1[i-1]+c,dp0[i-1]+c)
print(max(dp0[N],dp1[N],dp2[N]))

Measured memory_bytes: 65880
#include <iostream>

using namespace std;


int main () {
	int n, h[101], cnt = 0, tmp = -1;

	cin >> n;
	
	for (int i = 0; i < n; i++) {
		cin >> h[i];
		if (tmp <= h[i]) {
			cnt++;
			tmp = h[i];
		}
	}

	cout << cnt;


}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll n,a,b,ra[100001],fa[100001],ans;
vector<pair<ll,P>> s;
vector<pair<P,ll>> v,u;

ll find(ll x){
    if(x==fa[x])return x;
    return fa[x]=find(fa[x]);
}
void uni(ll x,ll y){
    x=find(x),y=find(y);
    if(x==y)return ;
    if(ra[x]<ra[y])swap(x,y);
    fa[y]=x;
    if(ra[x]==ra[y])ra[x]++;
    return ;
}
void ini(void){
    for(int i=0;i<100001;i++)fa[i]=i;
}

int main(void){
    cin>>n;
    ini();
    for(int i=0;i<n;i++){
        cin>>a>>b;
        v.push_back({{a,b},i});
        u.push_back({{b,a},i});
    }
    sort(v.begin(),v.end());
    sort(u.begin(),u.end());
    for(int i=0;i<n-1;i++){
        a=min(abs(v[i+1].F.F-v[i].F.F),abs(v[i+1].F.S-v[i].F.S));
        s.push_back({a,{v[i].S,v[i+1].S}});
        b=min((u[i+1].F.F-u[i].F.F),abs(u[i+1].F.S-u[i].F.S));
        s.push_back({b,{u[i].S,u[i+1].S}});
    }
    sort(s.begin(),s.end());
    for(auto x:s){
        //cout<<x.F<<" "<<" "<<x.S.S<<endl;
        if(find(x.S.F)!=find(x.S.S)){
            uni(x.S.F,x.S.S);
            ans+=x.F;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 14116