akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]
#![allow(unused_macros)]
use itertools::Itertools;
use std::cmp::{max, min};
use std::collections::*;
use std::io::{stdin, Read};

trait ChMinMax {
    fn chmin(&mut self, other: Self);
    fn chmax(&mut self, other: Self);
}
impl<T> ChMinMax for T
where
    T: PartialOrd,
{
    fn chmin(&mut self, other: Self) {
        if *self > other {
            *self = other
        }
    }
    fn chmax(&mut self, other: Self) {
        if *self < other {
            *self = other
        }
    }
}

#[allow(unused_macros)]
macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, $var:ident $($r:tt)*) => {
        let $var = parse_val!($it, usize);
        parse!($it $($r)*);
    };
}

#[allow(unused_macros)]
macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: tt),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, u1) => {
        $it.next().unwrap().parse::<usize>().unwrap() -1
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

#[cfg(debug_assertions)]
macro_rules! debug {
    ($( $args:expr ),*) => { eprintln!( $( $args ),* ); }
}

#[cfg(not(debug_assertions))]
macro_rules! debug {
    ($( $args:expr ),*) => {
        ()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    let s: Vec<_> = it.next().unwrap().chars().collect();
    let t: Vec<_> = it.next().unwrap().chars().collect();
    let mut ret = std::usize::MAX;
    for i in 0..=(s.len() - t.len()) {
        let mut count = 0;
        for j in 0..t.len() {
            if s[i + j] != t[j] {
                count += 1;
            }
        }
        ret.chmin(count);
    }
    println!("{}", ret);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 2120
import copy

def count_num_of_black(c):
    num = 0
    for row in c:
        for e in row:
            if e == '#':
                num += 1
    return num


if __name__ == "__main__":
    H, W, K = list(map(int, input().split()))
    original = []
    ans = 0
    for i in range(H):
        original.append(list(input()))
    for l in range(2 ** H):
        c = copy.deepcopy(original)
        for i in range(H):
            if ((l >> i) & 1):
                c[i] = list('*'*W)            
            c_after_line_change = copy.deepcopy(c)
        for r in range(2 ** W):
            c_before_row_change = copy.deepcopy(c_after_line_change)
            for j in range(W):
                if ((r >> j) & 1):
                    for k in range(H):
                        c_before_row_change[k][j] = '*'
            if K == count_num_of_black(c_before_row_change):
                ans += 1

    print(ans)


Measured memory_bytes: 9352
import java.util.*;
import java.awt.*;
import java.awt.geom.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        Scanner sc = new Scanner(in);
        int n=sc.nextInt();
        long ans=0;
        long[] c=new long[n];
        for (int i = 0; i < n; i++) {
            long A=sc.nextLong();
            long B=sc.nextLong();
            c[i]=A+B;
            ans-=B;
        }
        Arrays.sort(c);
        for (int i = 0; i < n; i+=2) {
            ans+=c[n-1-i];
        }
        out.println(ans);
    }
}

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

int mod = 1000000007;
int64_t large = 9223372036854775807;

int main()
{
    int N;
    cin >> N;
    vector<int> list(N);
    for (int i = 0; i < N; i++)
        cin >> list[i];

    int ans = 0;
    for (int i = 0; i < N - 2; i++)
        if ((list[i] < list[i + 1] && list[i + 1] < list[i + 2]) || (list[i] > list[i + 1] && list[i + 1] > list[i + 2]))
            ans++;
    cout << ans;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
const ll inf = 1e18;
const ll mod = 1e9 + 7;

ll pow (ll x, ll n){
    ll ans = 1;
    while(n>0){
        if(n & 1 == 1){
            ans *= x;
        }
        x = x * x;
        n >>= 1;
    }
    return ans;
}


int main(){
    int n;   cin >> n;
    vint a(n);
    for(int i=0; i < n; i++){
        cin >> a[i];
        a[i] = a[i] - (i+1);
    }

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

    ll b;
    if(n%2 == 0){
        b = ( a[n/2 -1] + a[n/2] ) /2;
    }else{
        b = a[n/2];
    }

    ll ans=0;
    rep(i,n){
        ans += abs(a[i]-b);
    }

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


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define va first
#define vb second
using namespace std;
typedef pair<int,int> pii;
const int MN = 2e5+5;
const int INF = 1e9;
int N,K,A[MN],L[MN][20],H[MN][20],I[MN],D[MN];
bool ch;
vector<int> V[4*MN];
set<pii> S;

int findL(int s, int e)
{
    int k=0;
    while(s+(1<<k)-1<=e) k++;
    k--;
    return min(L[s][k],L[e-(1<<k)+1][k]);
}

int findH(int s, int e)
{
    int k=0;
    while(s+(1<<k)-1<=e) k++;
    k--;
    return max(H[s][k],H[e-(1<<k)+1][k]);
}

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0);
    cin >> N >> K;
    for(int i=1; i<=N; i++){
        cin >> A[i];
        L[i][0] = H[i][0] = A[i];
        I[i] = D[i] = i;
    }
    for(int k=1; k<20; k++){
        for(int i=1; i<=N; i++){
            if(i+(1<<k-1)>N) L[i][k] = L[i][k-1], H[i][k] = H[i][k-1];
            else{
                L[i][k] = min(L[i][k-1],L[i+(1<<k-1)][k-1]);
                H[i][k] = max(H[i][k-1],H[i+(1<<k-1)][k-1]);
            }
        }
    }
    I[N] = N;
    for(int i=N-1; i>=1; i--){
        if(A[i]<A[i+1]) I[i] = I[i+1];
    }
    D[1] = 1;
    for(int i=2; i<=N; i++){
        if(A[i]>A[i-1]) D[i] = D[i-1];
    }
    int s,e,m,l,r;
    for(int i=1; i+K-1<=N; i++){
        s=i-1, e=i+K-1;
        while(s<e)
        {
            m = (s+e+1)/2;
            if(D[m]<=i&&findL(m,i+K-1)==A[m]) s=m;
            else e=m-1;
        }
        l = s+1;
        s=i, e=i+K;
        while(s<e)
        {
            m = (s+e)/2;
            if(I[m]>=i+K-1&&findH(i,m)==A[m]) e=m;
            else s=m+1;
        }
        r = e-1;
        if(i-1==r) S.insert(pii(0,0));
        else S.insert(pii(l,r));
        //cout << l << ' ' << r << '\n';
    }
    cout << S.size();
}


Measured memory_bytes: 61952
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, t = map(int, input().split())
    AB = sorted([list(map(int, input().split())) for _ in range(n)], key=lambda x: x[0])

    res = 0
    dp = [[0] * (t + 1) for _ in range(n + 1)]
    for i in range(1, n + 1):
        a, b = AB[i - 1]
        for j in range(1, t + 1):
            if j - a >= 0:
                dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - a] + b)
            else:
                dp[i][j] = max(dp[i - 1][j], dp[i][j])
        now = dp[i - 1][t - 1] + b
        res = max(res, now)

    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 145384
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#define ll long long
#define si(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define pi(n) prllf("%d",n)
#define pl(n) prllf("%d",n)
using namespace std;

int main(){
  int a,b;
  cin>>a>>b;
  if(a>8 || b>8) cout<<":(";
  else cout<<"Yay!";
}


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

int main(){
  int ans = 0;
  for(int i=0;i<5;i++){
    int x;
    scanf("%d",&x);
    if(x<=40) x = 40;
    ans+=x;
  }
  printf("%d\n",ans/5);
  return 0;
}

Measured memory_bytes: 2684
n, k = map(int, input().split())
maxim = (n-2) * (n-1) // 2
if k > maxim:
    print(-1)
    exit()

edges = [[x for x in range(n) if x > i] for i in range(n)]
count = 0
node = n-1
while count != k:
    if len(edges[node]) == 0:
        node -= 1
    edges[node].pop()
    count += 1

m = n * (n-1) // 2 - k
print(m)
for _from in range(n-1):
    for to in edges[_from]:
        print(_from+1, to+1)

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin>>N;
  double sum=0;
  for(int i=0;i<N;i++){
    double x;
    string u;
    cin>>x>>u;
    if(u=="JPY")sum+=x;
    else sum+=x*380000.0;
  }
  cout<<sum<<endl;
}
  


Measured memory_bytes: 256
#include <cstdio>
int n, c, a[100005];
int main() {
	int i, j;
	scanf("%d", &n);
	for(i=1; i<=n; i++) scanf("%d", &a[i]);
	for(i=1; i!=2 && a[i]>0; ) {
		c++;
		j = a[i];
		a[i] = 0;
		i = j;
	}
	printf("%d", i==2 ? c:-1);
	return 0;
}

Measured memory_bytes: 640
import sys
input = sys.stdin.readline

N, K = map(int, input().split())
A = [0] + list(map(int, input().split()))

Seq = [-1]*(N+1)
Seq[1] = 0
now = 1
while True:
    n = A[now]
    if Seq[n] == -1:
        Seq[n] = Seq[now] + 1
        now = n
    else:
        cycle = Seq[now] + 1 - Seq[n]
        now = n
        break

if Seq[now] > K:
    for n in range(N+1):
        if Seq[n] == K:
            print(n)
            break
else:
    rem = (K-Seq[now])%cycle
    for _ in range(rem):
        now = A[now]
    print(now)

Measured memory_bytes: 100060
package main

import (
	"io"
	"os"

	"fmt"
)

func Solve(in io.Reader, out io.Writer) {
	var a, b int
	fmt.Fscan(in, &a, &b)

	if a <= 8 && b <= 8 {
		fmt.Fprintln(out, "Yay!")
	} else {
		fmt.Fprintln(out, ":(")
	}

}

func main() {
	Solve(os.Stdin, os.Stdout)
}


Measured memory_bytes: 512
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    a = n // 2
    b = n - a

    return a * b


print(main())


Measured memory_bytes: 5460
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) (y) < 0 || h <= (y) || (x) < 0 || w <= (x)
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
const long double eps = 1e-10;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();

    int n; string s; cin >> n >> s;
    if (n % 2 == 0 && s.substr(0, n / 2) == s.substr(n / 2)) {
        cout << "Yes\n";
    }
    else cout << "No\n";
}


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

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
void printhour(int S){
  int s = S % 60;
  S /= 60;
  int m = S % 60;
  int h = S / 60;
  printf("%02d:%02d:%02d", h, m, s);
}

int calc(int h, int m, int s){
  int ms = m * 60 + s;
  int hour = h / 5;
  int res = hour * 60 * 60 + ms;
  int check = (h % 5) * 12 * 60;
  if(check <= ms && ms < check + 12 * 60){
    //printf("%d %d %d -> ", h, m, s);
    //printhour(res);
    return res;
  }else{
    return -1;
  }
}
int tosecond(int h, int m, int s){
  return s + m * 60 + h * 60 * 60;
}
bool contain(int n, int ok[], int s1, int s2){
  int S = 0;
  for(int i = s1; i <= s2; i++){
    S |= ok[i];
  }
  return S == ((1<<n) - 1);
}

int main(){
  int n;
  while(cin>>n && n){
    int s[3];
    int ok[43200] = {};
    REP(i, n){
      REP(j, 3) cin>>s[j];
      sort(s, s + 3);
      do{
        REP(j, 60){
          int result = calc((s[0] + j) % 60, (s[1] + j) % 60, (s[2] + j) % 60);
          if(result != -1) ok[result] |= 1<<i;
        }
      }while(next_permutation(s, s+3));
    }
    int b = 0, e = 0, S = 0;
    int ans1, ans2;
    int mini = INF;
    while(b < 43200){
      while(e < 43200 && S != ((1<<n)-1)){
        S |= ok[e];
        e++;
      }
      if(S != ((1<<n)-1)) break;
      if(mini > e - b){
        mini = e - b;
        ans1 = b, ans2 = e - 1;
      }
      S ^= (ok[b]);
      b++;
      e = b;
      S = 0;
    }
    printhour(ans1); putchar(' '); printhour(ans2); putchar('\n');
  }
  return 0;
}

Measured memory_bytes: 1052
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll GCD(ll a, ll b){ return a ? GCD(b % a, a) : b; }
int main(){
    int s,w;
    cin>>s>>w;
    if(s<=w) cout<<"un";
    cout<<"safe"<<endl;
}

Measured memory_bytes: 3624
p = input()
a = map(int, raw_input().strip().split())
b = [0] * p

p2 = p * p

s = []
for i in xrange(p):
    if a[i]: s.append(i)

ncr = [[0 for i in xrange(p)] for j in xrange(p)]

for i in xrange(p):
    ncr[i][0] = ncr[i][i] = 1
    ncr[i][1] = i

for n in xrange(2, p):
    for r in xrange(2, n):
        ncr[n][r] = ncr[n - 1][r] + ncr[n - 1][r - 1]
        if (ncr[n][r] >= p): ncr[n][r] -= p

jpow = [[0 for i in xrange(p)] for j in xrange(p)]
jpow[0][0] = 1

for i in xrange(1, p):
    val = 1
    for j in xrange(p):
        jpow[i][j] = val
        val *= i
        if (val >= p): val %= p

for r in xrange(1, p):
    for j in s:
        x = ncr[p - 1][r]
        x *= jpow[j][p - 1 - r]
        if (x >= p2): x %= p

        if (p - r) & 1: b[r] -= x
        else: b[r] += x

    if b[r] >= p or b[r] < 0: b[r] %= p

if a[0]: b[0] = 1

print ' '.join(map(str, b))

Measured memory_bytes: 174748
#include<bits/stdc++.h>
using namespace std;
int main() {
	int N,A[100010],ans=0 ;
    cin>>N;
	for (int i = 0; i < 100010; i++) {
		A[i] = 0;
	}
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < N; i++) {
		if (A[i] % 2 != 0) {
			ans++;
		}
	}
	if (ans % 2 == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define PI (acos(-1))

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;
}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e15;
const int INF=1e9;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,W;
	cin>>n>>W;
	vector<int> w(n),v(n);
	vector<vector<ll>> dp(n+1,vector<ll>(W+1,0));
	rep(i,n){
		int w,v;
		cin>>w>>v;
		rep(j,W+1){
			chmax(dp[i+1][j],dp[i][j]);
			if(j-w>=0) chmax(dp[i+1][j],dp[i][j-w]+v);
		}
	}
	cout<<dp[n][W]<<endl;
}

Measured memory_bytes: 80256
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAX_N = 128;
int N, K;
int X[MAX_N];
int main(){
scanf("%d", &N);
scanf("%d", &K);
for(int i = 0; i < N; ++i){
scanf("%d", X + i);
}
int ans = 0;
for(int i = 0; i < N; ++i){
ans += min(X[i], K - X[i]) * 2;
/*  int tmp = min(X[i], K - X[i]);
ans += tmp;*/
}
printf("%d\n", ans);
return 0;
}

Measured memory_bytes: 128
//
//  sublime text 3,
//  emre yazicioglu
//

#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair <ll, ll> pll;
typedef vector <ll> vll;
typedef vector <pll> vpll;
#define pb push_back
#define fi first
#define se second
#define INF (ll) (1e18 + 7)
#define MOD (ll) (1e9 + 7)

const int N = 2e6 + 7;
ll mn = INF, mx = -INF;
ll n, m, k, s, q, t;
ll a, b, c, d, e;
ll ans, cur, sum, cnt;
ll ar[N], p[N], dp[N];
string str; bool h[N];
pll pp[N]; vll v;

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

  // freopen("../in.txt","r",stdin);
  // freopen("../out.txt","w",stdout);

  cin >> n;
  for(int i = 1; i <= n; i++) {
    cin >> a;
    ar[a] = i;
  }
  for(int i = 1; i <= n; i++)
    cout << ar[i] << ' ';
}

Measured memory_bytes: 4992
#include <iostream>
#include <string>
using namespace std;
int main() {
    int n, k, t=0;
    cin >> n >> k;
    string s;
    cin >> s;
    int x;
    x= int(s.size());
    for (int i=1; i < x ; i++) {
        if (s[i]== s[i-1])
            t = t + 1;
        
    }
    if (t + 2 * k < n)
        cout << t + 2 * k;
    else
        cout << n - 1;
    return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <iostream>
#include <bitset>
using namespace std;
#define N 305
#define ll long long
#define mod 998244353
int n,a[N],f[N*N],g[N*N],sum,ans,tmp;
int main()
{
	scanf("%d",&n);tmp=1;
	for(int i=1;i<=n;i++)scanf("%d",&a[i]),tmp=tmp*3ll%mod;f[0]=1;g[0]=1;
	for(int i=1;i<=n;i++)
	{
		sum+=a[i];
		for(int j=sum;j>=a[i];j--)
			f[j]=((ll)f[j]*2+f[j-a[i]])%mod,(g[j]+=g[j-a[i]])%=mod;
		for(int j=0;j<a[i];j++)f[j]=(f[j]<<1)%mod;
	}
	for(int i=(sum+1)>>1;i<=sum;i++)(ans+=f[i])%=mod;
	if(!(sum&1))ans-=g[sum>>1];
	printf("%lld\n",((tmp-ans*3ll)%mod+mod)%mod);
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

constexpr lint inf = 1e18;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, m, l; cin >> n >> m >> l;
  VV<lint> g(n, V<lint>(n, inf));
  for (int v = 0; v < n; ++v) {
    g[v][v] = 0;
  }
  while (m--) {
    int u, v, w; cin >> u >> v >> w, --u, --v;
    if (w > l) continue;
    g[u][v] = g[v][u] = w;
  }
  VV<> res(n, V<>(n));
  for (int s = 0; s < n; ++s) {
    V<lint> d(n + 1, inf);
    d[s] = 0;
    V<bool> vis(n);
    while (true) {
      int v = n;
      for (int u = 0; u < n; ++u) if (not vis[u] and d[u] < d[v]) {
        v = u;
      }
      if (v == n) break;
      if (d[v] > l) {
        for (int u = 0; u < n; ++u) if (d[u] > l) {
          ++res[s][u];
          d[u] = inf;
        }
        V<bool> b(n);
        for (int u = 0; u < n; ++u) if (d[u] and d[u] <= l) {
          d[u] = 0;
          b[u] = true;
        }
        for (int u = 0; u < n; ++u) if (b[u]) {
          for (int w = 0; w < n; ++w) {
            d[w] = min(d[w], g[u][w]);
          }
        }
      } else {
        vis[v] = true;
        for (int u = 0; u < n; ++u) {
          d[u] = min(d[u], d[v] + g[v][u]);
        }
      }
    }
  }
  for (int k = 0; k < n; ++k) for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) {
    g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
  }
  for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) if (g[i][j] == inf) {
    res[i][j] = -1;
  }
  int q; cin >> q;
  while (q--) {
    int s, t; cin >> s >> t, --s, --t;
    cout << res[s][t] << '\n';
  }
}

Measured memory_bytes: 1664
import itertools
n, m, r = map(int, input().split())
t = list(map(int, input().split()))
t.sort()
d = [[10 ** 18]*n for j in range(n)]
for i in range(n):
    d[i][i] = 0

for i in range(m):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    d[a][b] = c
    d[b][a] = c

for k in range(n):
    for i in range(n):
        for j in range(n):
            d[i][j] = min(d[i][j], d[i][k] + d[k][j])


ans = 10**18
for p in itertools.permutations(t):
    now = 0
    for i in range(r-1):
        now += d[p[i]-1][p[i + 1]-1]
    ans = min(ans, now)
print(ans)


Measured memory_bytes: 46808
#include<bits/stdc++.h>
using namespace std;
long long int dis[10000000];
bool vis[10000000];
vector < long long int> adj[1000000];




long long int dfs(int n)
{
vis[n]=true;

long long int max1=0;
for(int it: adj[n])
{if(!vis[it])max1=max(max1,dfs(it)+1);
else{max1=max(max1,dis[it]+1);}
}
dis[n]=max1;
//cout<<max1<<" "<<n<<endl;
return max1;
}


main(){
long long n,m;
cin>>n>>m;
for(int i=0,a,b;i<m;i++)
{cin>>a>>b;
adj[a-1].push_back(b-1);
}

memset(vis,false,sizeof(vis));
for(int i=0;i<n;i++)
{if(!vis[i])dis[i]=dfs(i);}
long long int mx=0;
for(int i=0;i<n;i++)
mx=max(mx,dis[i]);
cout<<mx;
}


Measured memory_bytes: 43236
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim_end().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn invec(v: &Vec<i16>, x: i16) -> bool {
    for i in v {
        if i == &x {
            return true
        }
    }
    false
}
fn main() {
    let v: Vec<i16> = read_vec();
    let p: Vec<i16> = read_vec();
    let x = v[0];
    //let n = v[1];
    for i in 0..100 {
        if !invec(&p, x - i) {
            println!("{}", x - i);
            return
        }
        if !invec(&p, x + i) {
            println!("{}", x + i);
            return
        }
    }
}


Measured memory_bytes: 2084
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
#include <numeric>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<P> vp;
typedef vector<bool> vb;
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define rrep(i, a, n) for (ll i = (a); i > (n); --i)
#define erep(i, a, n) for (ll i = (a); i <= (n); ++i)
#define rerep(i, a, n) for (ll i = (a); i >= (n); --i)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define print(X) cout << (X) << "\n"
#define _ << " " <<
static const int INF = 1e+9+7;

int main(){
    while(1){
      int a,b;
      str op;
      cin >> a >> op >> b;
      if(op == "?") break;
      if(op == "+") print(a+b);
      else if(op == "-") print(a-b);
      else if(op == "*") print(a*b);
      else print(a/b);
    }


  return 0;
}





Measured memory_bytes: 3140
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().solve();
	}

	private void solve() throws IOException {
		try {
			solveA();
			// solveB();
			// solveC();
			// solveD();
			// solveE();
			// solveF();
		} finally {
			if (in != null) {
				in.close();
			}
			if (out != null) {
				out.flush();
				out.close();
			}
		}

	}

	private void solveA() {
		int numA = nextInt();
		int numB = nextInt();
		int numC = nextInt();

		if (numB - numA == numC - numB) {
			out.println("YES");
		} else {
			out.println("NO");
		}

		out.println("");
	}

	private void solveB() {
		int numN = nextInt();

		out.println("");
	}

	private void solveC() {
		int numN = nextInt();

		out.println("");
	}

	private void solveD() {
		int numN = nextInt();

		out.println("");
	}

	private void solveE() {
		int numN = nextInt();

		out.println("");
	}

	private void solveF() {
		int numN = nextInt();

		out.println("");
	}

	private final PrintWriter out = new PrintWriter(System.out);
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
}

Measured memory_bytes: 23124
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <string>

using namespace std;

int N, A, X[51];
long long ans = 0, dp[51][51][3000];

int main() {

	cin >> N >> A;

	for (int i = 1; i <= N; i++) {
		cin >> X[i];
	}
	
	dp[0][0][0] = 1;

	for (int j = 1; j <= N; j++) {
		for (int k = 0; k <= N; k++) {
			for (int s = 0; s <= 50*N; s++) {
				//cout << "j: " << j << " k: " << k << " X[j]: " << X[j] << endl;
				if (s < X[j]) {
					dp[j][k][s] = dp[j - 1][k][s];
				}
				else if (X[j] <= s && 1 <= k) {	//k>=1でないと、選ぶ選ばないの話ができない
					dp[j][k][s] = dp[j - 1][k][s] + dp[j - 1][k-1][s-X[j]];
				}else{
					dp[j][k][s] = 0;
				}
			}
		}
	}

	for (int k = 1; k <= N; k++) {
		ans += dp[N][k][k*A];
	}

	cout << ans << endl;

	return 0;
}

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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#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 SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const long long MOD = 1000000007LL;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

template<typename T>
bool chmax(T &_a, T _b){
    if(_a < _b){
        _a = _b;
        return true;
    }else{
        return false;
    }
}

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

    lint n, ga, sa, ba, gb, sb, bb;
    cin >> n >> ga >> sa >> ba >> gb >> sb >> bb;

    vector<lint> dp1(n + 1);
    rep(i, n){
        chmax(dp1[i + 1], dp1[i]);
        if(i + ga <= n){
            chmax(dp1[i + ga], dp1[i] + (gb - ga));
        }
        if(i + sa <= n){
            chmax(dp1[i + sa], dp1[i] + (sb - sa));
        }
        if(i + ba <= n){
            chmax(dp1[i + ba], dp1[i] + (bb - ba));
        }
    }

    n += dp1[n];

    vector<lint> dp2(n + 1);
    rep(i, n){
        chmax(dp2[i + 1], dp2[i]);
        if(i + gb <= n){
            chmax(dp2[i + gb], dp2[i] + (ga - gb));
        }
        if(i + sb <= n){
            chmax(dp2[i + sb], dp2[i] + (sa - sb));
        }
        if(i + bb <= n){
            chmax(dp2[i + bb], dp2[i] + (ba - bb));
        }
    }

    n += dp2[n];

    cout << n << endl;

    return 0;
}

Measured memory_bytes: 195584
#![allow(non_snake_case)]
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let X:usize = sc.read();
    let Y:usize = sc.read();
    let mut ans:usize = 0;
    if X == 1{
        ans += 300_000;
    }else if X == 2{
        ans += 200_000;
    }else if X == 3{
        ans += 100_000;
    }
    if Y == 1{
        ans += 300_000;
    }else if Y == 2{
        ans += 200_000;
    }else if Y == 3{
        ans += 100_000;
    }

    if (X == 1) && (Y == 1) {
        ans += 400_000;
    }
    println!("{}", ans);
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
        .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}




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

int dp[4040][4040];
const int INF=1e9;

int sr[4040][2];
int tr[4040][2];

int main(){
  string S,T;
  cin>>S;
  cin>>T;
  int N=S.size(),M=T.size();
 
  sr[N+1][0]=N+1;
  sr[N+1][1]=N+1;
  for(int i=N;i>=0;i--){
    sr[i][0]=sr[i+1][0];
    sr[i][1]=sr[i+1][1];
    if(i==N) continue;
    if(S[i]=='0') sr[i][0]=i;
    else sr[i][1]=i;
  }

  tr[M+1][0]=M+1;
  tr[M+1][1]=M+1;
  for(int i=M;i>=0;i--){
    tr[i][0]=tr[i+1][0];
    tr[i][1]=tr[i+1][1];
    if(i==M) continue;
    if(T[i]=='0') tr[i][0]=i;
    else tr[i][1]=i;
  }

  for(int i=0;i<=N+1;i++) for(int j=0;j<=M+1;j++) dp[i][j]=INF;
  dp[N+1][M+1]=0;
  for(int i=N+1;i>=0;i--){
    for(int j=M+1;j>=0;j--){
      for(int k=0;k<2;k++){
        dp[i][j]=min(dp[i][j],dp[min(N+1,sr[i][k]+1)][min(M+1,tr[j][k]+1)]+1);
      }
    }
  }

  string ans="";
  int x=0,y=0;
  while(1){
    if(x==N+1&&y==M+1) break;
    for(int k=0;k<2;k++){
      if(dp[x][y]-1==dp[min(N+1,sr[x][k]+1)][min(M+1,tr[y][k]+1)]){
        x=min(N+1,sr[x][k]+1);
        y=min(M+1,tr[y][k]+1);
        ans=ans+char('0'+k);
        break;
      }
    }
  }

  cout<<ans<<endl;


  return 0;
}



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

int main()
{
	int a,b;
	cin >> a >> b;
	string S = "", T = "";
	rep(i,a)
	{
		S += (b+'0');
	}
	rep(i,b)
	{
		T += (a+'0');
	}
	if (S < T)
	{
		cout << S << endl;
	}
	else
	{
		cout << T << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
int main() {
	string s;
	string t;
	int a;
	int b;
	cin >> s >> t;
	cin >> a >> b;
	string u;
	cin >> u;
	if (u == s) {
		a = a - 1;
	}
	else {
		b = b - 1;
	}
	cout << a << " " << b;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)                                                         

using namespace std;
#define ll long long

int main(){
  string S;
  cin >> S;
  int len = S.size();
  for(int i=len/2*2-2; i>0; i-=2){
    bool ret = true;
    for(int j=0; j<i/2; j++){
      if(S[j] != S[i/2+j]){
        ret = false;
        break;
      }
    }
    if(ret){
      cout << i <<endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[100010],s=0;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=2*n;i++)
        scanf("%d",&a[i]);
    sort(a+1,a+1+2*n);
    for(int i=1;i<=2*n;i+=2)
        s+=a[i];
    printf("%d\n",s);
    return 0;
 } 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>
using namespace std;
int main(){
    int n,box=0;
    cin >> n;
    int A[7] = {1,2,4,8,16,32,64};
    for(int i=0;i<7;i++){
        if(A[i]<=n){
            swap(A[i],box);
        }
    }
    cout << box;
    return 0;
}

Measured memory_bytes: 3616
#!usr/bim/python
#! -*- coding: utf-8 -*-

hw = raw_input()
h,w = hw.split()
h = int(h)
w = int(w)

al = [chr(i) for i in range(97, 97+26)]

a = ""
for i in range(h):
    s = raw_input()
    a += s

#print a

#print al

c = []

for x in al:
    count = a.count(x)
    c.append(count)

#print c

status1 = 0
status2 = 0
for x in c:
    if x % 4 == 0:
        pass
    elif x % 2 == 0:
        status1 += 1
    else:
        status2 += 1

ans = 0
if h % 2 == 0 and w % 2 == 0:
    if status1 > 0 or status2 > 0:
        ans = 1
elif h % 2 == 0:
    if status2 > 0:
        ans = 1
    elif status1 > h / 2:
        ans = 1
elif w % 2 == 0:
    if status2 > 0:
        ans = 1
    elif status1 > w / 2:
        ans = 1
else:
    if status2 > 1:
        ans = 1
    elif status1 > h / 2 + w / 2:
        ans = 1

if ans == 0:
    print "Yes"
else:
    print "No"


Measured memory_bytes: 2820
#include<stdio.h>
int main(void){
	int n, a[100], v, i, j, k, last;
	
	scanf("%d\n", &n);
	last = n-1;
	for(k = 0; k < n; k++){
		if(k == last){
			scanf("%d\n", &a[k]);
			break;
		}
		scanf("%d ", &a[k]);
	}
	for(k = 0; k < n; k++){
		if(k == last){
			printf("%d\n", a[k]);
			break;
		}
		printf("%d ", a[k]);
	}
	for(i = 1; i < n; i++){
		v = a[i];
		j = i - 1;
		while(a[j] > v && j >= 0){
			a[j+1] = a[j];
			j--;
		}
		a[j+1] = v;
		for(k = 0; k < n; k++){
			if(k == last){
				printf("%d\n", a[k]);
				break;
			}
			printf("%d ", a[k]);
		}
	}
	
	return 0;
}


Measured memory_bytes: 2124
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
const long long INF = 1LL << 60;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  string S,T;
  cin >> S >> T;
  int count = 0;
  int N = S.size();
  rep(i,N)
  {
    if(S[i]!=T[i])
    {
      count ++;
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 3916
import sys
from collections import deque
read = sys.stdin.read
readline = sys.stdin.buffer.readline
INF = float('inf')

class Dinic:
    def __init__(self, N):
        self.N = N
        self.G = [[] for i in range(N)]

    def add_edge(self, fr, to, cap):
        forward = [to, cap, None]
        forward[2] = backward = [fr, 0, forward]
        self.G[fr].append(forward)
        self.G[to].append(backward)

    def add_multi_edge(self, v1, v2, cap1, cap2):
        edge1 = [v2, cap1, None]
        edge1[2] = edge2 = [v1, cap2, edge1]
        self.G[v1].append(edge1)
        self.G[v2].append(edge2)

    def bfs(self, s, t):
        self.level = level = [None]*self.N
        deq = deque([s])
        level[s] = 0
        G = self.G
        while deq:
            v = deq.popleft()
            lv = level[v] + 1
            for w, cap, _ in G[v]:
                if cap and level[w] is None:
                    level[w] = lv
                    deq.append(w)
        return level[t] is not None

    def dfs(self, v, t, f):
        if v == t:
            return f
        level = self.level
        for e in self.it[v]:
            w, cap, rev = e
            if cap and level[v] < level[w]:
                d = self.dfs(w, t, min(f, cap))
                if d:
                    e[1] -= d
                    rev[1] += d
                    return d
        return 0

    def flow(self, s, t):
        flow = 0
        G = self.G
        while self.bfs(s, t):
            *self.it, = map(iter, self.G)
            f = INF
            while f:
                f = self.dfs(s, t, INF)
                flow += f
        return flow

def main():
    N = int(readline())

    AB = []
    for _ in range(N):
        a, b = map(int, readline().split())
        AB.append([a,b])

    CD = []
    for _ in range(N):
        c, d = map(int, readline().split())
        CD.append([c,d])

    dinic = Dinic(2*N+2)

    for i in range(N):
        a, b = AB[i]
        for j in range(N):
            c, d = CD[j]
            if a<c and b<d:
                dinic.add_edge(i+1,N+j+1,1)

    for i in range(N):
        dinic.add_edge(0, i+1, 1)
        dinic.add_edge(N+i+1, 2*N+1, 1)

    ans = dinic.flow(0, 2*N+1)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 4064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;

class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] str = br.readLine().split(" ");

		int n = Integer.parseInt(str[0]);

		int q = Integer.parseInt(str[1]);

		Deque<String> dq = new ArrayDeque<>();

		for (int i = 0; i < n; i++) {
			String[] name_time = br.readLine().split(" ");

			dq.offerLast(name_time[0]);
			dq.offerLast(name_time[1]);

		}

		int[] total_time = new int[n];
		String[] name = new String[n];

		int a = 0;
		int p = 0;
		while (!(dq.isEmpty())) {

			String Now_name = dq.pollFirst();

			int now_time = Integer.parseInt(dq.pollFirst());
			/*
			 * System.out.println(Now_name+" "+now_time);
			 */
			if (now_time - q > 0) {
				dq.offerLast(Now_name);
				dq.offerLast(String.valueOf(now_time - q));

				a += q;
			} else {
				a += now_time;
				total_time[p] = a;
				name[p] = Now_name;

				p++;
			}

		}

		for (int i = 0; i < n; i++) {
			System.out.println(name[i] + " " + total_time[i]);
		}
	}
}

Measured memory_bytes: 78356
s = gets.to_i
N = 10 ** 6

arr = []
for i in 1..N do
  if i == 1 then
    arr[i-1] = s
  elsif arr[i-2] % 2 == 0 then
    arr[i-1] = arr[i-2] / 2
  else
    arr[i-1] = 3 * arr[i-2] + 1
  end
end
    
deja = []
for i in 1..N do
  deja[i-1] = false
end
    
m = 1
loop do
  num = arr[m-1]
  if deja[num-1] then
    puts m
    break
  else
    deja[num-1] = true
  end
  m += 1
end

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

const int MAX_N = 1e5;
int N;
int M;
int f[MAX_N+1];
bool is_f[MAX_N+1];
int ans;
int find(int x){return f[x]?f[x]=find(f[x]):x;}
void merge(int x,int y)
{
	int fx = find(x);
	int fy = find(y);
	if ( fx != fy )
		f[fx] = fy;
	return;
}
int main()
{
	scanf("%d%d",&N,&M);
	for ( int i = 0 ; i < M ; i++ )
	{
		int X,Y,Z;
		scanf("%d%d%d",&X,&Y,&Z);
		merge(X,Y);
	}
	for ( int i = 1 ; i <= N ; i++ )
		is_f[find(i)] = true;	
	for ( int i = 1 ; i <= N ; i++ )
		ans += is_f[i];
	printf("%d",ans);
	printf("\n");
	return 0;
}

Measured memory_bytes: 1152
N,K=map(int,input().split())
A=list(map(int,input().split()))
flag=0
B=[0]*10
for i in range(len(A)):
    B[A[i]]+=1
for i in range(N,100000):
    flag = 0
    k = str(i)
    for j in range(len(k)):
        if B[int(k[j])]==1:
            flag=1
    if flag==0:
        print(k)
        exit(0)

Measured memory_bytes: 3064
import java.util.*;
import java.lang.*;

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*c) > b){
            System.out.println((b/a));
        }else{
            System.out.println(c);
        }
        System.out.println();
        sc.close();
    }
}

Measured memory_bytes: 20948
H,W=gets.split.map(&:to_i)
N=gets.to_i
A=gets.split.map(&:to_i)

data=[]
N.times do |i|
    data += [i+1]*A[i]
end

cnt=0
ans=Array.new(H){Array.new(W, 0)}
H.times do |i|
    if i % 2 == 0
        (0..W-1).each do |j|
            ans[i][j] = data[cnt]
            cnt+=1
        end
    else
        (0..W-1).each do |j|
            ans[i][W-1-j] = data[cnt]
            cnt+=1
        end
    end
    puts ans[i].join(" ")
end


Measured memory_bytes: 54688
#include<stdio.h>
#include<stdint.h>
#include<inttypes.h>

typedef struct{
    uint8_t suit ;
    uint8_t value;
} card_s;

void swap_card(card_s *c1, card_s *c2)
{
    card_s tmp = *c1;
    *c1        = *c2;
    *c2        = tmp;
}

void bubble_sort_card(card_s *c, uint8_t n)
{
    for(uint8_t i=0; i<n-1; ++i)
        for(uint8_t j=n-1; j>i; --j)
            if(c[j].value < c[j-1].value)
                swap_card(&c[j], &c[j-1]);
}

void selection_sort_card(card_s *c, uint8_t n)
{
    for(uint8_t i=0; i<n; ++i){
        uint8_t minj = i;
        for(uint8_t j=i+1; j<n; ++j)
            if(c[j].value < c[minj].value)
                minj = j;
        if(minj != i)
            swap_card(&c[i], &c[minj]);
    }
}

void print_card_array(card_s *c, uint8_t n)
{
    printf("%c%"PRIu8, c[0].suit, c[0].value);
    for(uint8_t i=1; i<n; ++i)
        printf(" %c%"PRIu8, c[i].suit, c[i].value);
    printf("\n");
}

uint8_t card_array_is_same(card_s *c1, card_s *c2, uint8_t n)
{
    for(uint8_t i=0; i<n; ++i){
        if(c1[i].suit != c2[i].suit)
            return 0;
        if(c1[i].value != c2[i].value)
            return 0;
    }
    return 1;
}

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

    card_s c[n];
    scanf("\n%c%"PRIu8, &c[0].suit, &c[0].value);
    for(uint8_t i=1; i<n; ++i)
        scanf(" %c%"PRIu8, &c[i].suit, &c[i].value);

    card_s c_bubble[n], c_selection[n];
    for(uint8_t i=0; i<n; ++i){
        c_bubble[i] = c_selection[i] = c[i];
    }
    bubble_sort_card   (c_bubble   , n);
    selection_sort_card(c_selection, n);

    print_card_array(c_bubble   , n);
    printf("Stable\n");
    print_card_array(c_selection, n);
    if(card_array_is_same(c_bubble, c_selection, n)){
        printf("Stable\n");
    }else{
        printf("Not stable\n");
    }

    return 0;
}

Measured memory_bytes: 1860
import java.util.*;
import java.math.*;
     
class Main{
    public static void main(String[] args) {
        
        try(Scanner sc = new Scanner(System.in)){
            String abc = sc.next();

            int countA = 0, countB = 0, countC = 0;

            for(int i = 0; i < 3; i++){
                String str = abc.substring(i, i + 1);
                if(str.equals("a")) countA++;
                else if(str.equals("b")) countB++;
                else if(str.equals("c")) countC++;
            }

            if(countA == 1 && countB == 1 && countC == 1){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }

        }catch(Exception e){
            e.printStackTrace();
        }        
    }
}

Measured memory_bytes: 23892